how to view WAL logs of GCP Postgres SQL instance (cloudsql) - google-cloud-sql

try to find out wal log path ? and how i can export it ?
gone though official doc -https://cloud.google.com/sql/docs/postgres/replication/configure-logical-replication
tried firing Select * from pg_current_wal_location(); but getting error.

Related

what is the table name that postgres uses to log errors

I am new to Postgres and would like to know if there is a table where Postgres logs the errors if there is any. Something similar to the Oracle equivalent = dba_errors
Errors are logged to the error log, see the documentation. You can log to a file, the syslog daemon (on Unix) or the event log (on Windows).
There is no support for logging to a table, bbut you can load a CSV log file into a table.

AWS RDS PostgreSQL - Indexes being dropped automatically shortly after creation

I'm creating indexes via pgAdmin for my PostgreSQL database hosted via AWS RDS with the following command:
CREATE INDEX team_idx_teamid ON team ("teamId");
Which returns the response:
Query returned successfully in 1 secs 575 msec.
And it is displayed in pgAdmin UI:
After a few minutes it disappears. Looking at the event logs in AWS I see the following message:
2021-06-21 11:21:58 UTC:13.58.56.170(51704):[16657]:STATEMENT: DROP INDEX "team_idx_teamid"
I can't find anything related to why indexes are being dropped or cleaned up in my google searches. Anyone got any ideas of what is going on?
Many thanks

How to View Full text of Top query in AWS RDS Postgres - performace insights

I'm using the Postgres database from AWS RDS. I want to see the full text of Top query in AWS RDS performance insights.
Link: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_PerfInsights.UsingDashboard.html#USER_PerfInsights.UsingDashboard.SQLTextLimit
As per the documentation, I've updated the track_activity_query_size to the max: 102400, have also tried rebooting the Postgres DB instance, still, it shows the same truncated <= 500 chars.
PS: my Postgres DB instance version is 12.5
Can someone help?
You can enable the PostgresSQL logs and search the half length queries in the latest logs wherein you will get the full length queries of the same.
Go to the "Logs & events" tab in the respective database from RDS console and download the log. Then search using some file editor to get the full length queries.

SQL query to tell when server no longer has the requested starting point

I have a master-slave setup using postgres 9.5.3 and got the following error in my postgres log
"could not start WAL streaming: ERROR: requested starting point 0/D000000 on timeline 2 is not in this server's history"
I would like to know if there is sql query that can tell me that my server no longer has the requested starting point so I will be able to automatically start full copy of the master data directory.
Thanks
Avi
I don't think that you can get this information with SQL; you'd have to examine the contents of pg_xlog.
Wouldn't it be a better solution to use a replication slot to ensure that WAL is kept long enough?

DB2: not able to restore from backup

I am using command
db2 restore db S18 from /users/intadm/s18backup/ taken at 20110913113341 on /users/db2inst1/ dbpath on /users/db2inst1/ redirect without rolling forward
to restore database from backup file located in /users/intadm/s18backup/ .
Command execution gives such output:
SQL1277W A redirected restore operation is being performed. Table space
configuration can now be viewed and table spaces that do not use automatic
storage can have their containers reconfigured.
DB20000I The RESTORE DATABASE command completed successfully.
When I'm trying to connect to restored DB (by executing 'db2 connect to S18'), I'm getting this message:
SQL0752N Connecting to a database is not permitted within a logical unit of
work when the CONNECT type 1 setting is in use. SQLSTATE=0A001
When I'm trying to connect to db with db viewer like SQuireL, the error is like:
DB2 SQL Error: SQLCODE=-1119, SQLSTATE=57019, SQLERRMC=S18, DRIVER=3.57.82
which means that 'error occurred during a restore function or a restore is still in progress' (from IBM DB2 manuals)
How can I resolve this and connect to restored database?
UPD: I've executed db2ckbkp on backup file and it did not identified any issues with backup file itself.
without rolling forward can only be used when restoring from an offline backup. Was your backup taken offline? If not, you'll need to use roll forward.
When you do a redirected restore, you are telling DB2 that you want to change the locations of the data files in the database you are restoring.
The first step you show above will execute very quickly.
Normally, after you execute this statement, you would have one or more SET TABLESPACE CONTAINERS to set the new locations of each data file. It's not mandatory to issue these statements, but there's no point in specifying the redirect option in your RESTORE DATABASE command if you're not changing anything.
Then, you would issue the RESTORE DATABASE S18 COMPLETE command, which would actually read the data from the backup image, writing it to the data files.
If you did not execute the RESTORE DATABASE S18 COMPLETE, then your restore process is incomplete and it makes sense that you can't connect to the database.
What I did and what has worked:
Executed:
db2 restore db S18 from /users/intadm/s18backup/ taken at 20110913113341 on /<path with sufficient disk space> dbpath on /<path with sufficient disk space>
I got some warnings before, that some table spaces are not moved. When I specified dbpath to partition with sufficient disk space - warning has disappeared.
After that, as I have an online backup, I issued:
db2 rollforward db S18 to end of logs and complete
That's it! Now I'm able to connect.