Home > Back-end >  Determine PostgreSQL mode
Determine PostgreSQL mode

Time:10-20

I have inherited a PostgreSQL 13 cluster which was setup using log shipping. I had to make a few changes and would to confirm everything is working well.

  1. Is there a command to make pgsql report whether it is in standby mode or active mode?

  2. Is there a command to make pgsql report up to which WAL file it has applied changes?

  3. I assume that the only way to test the wal shipping is working is to manually modify the active db server and watch for the change on the standby?

I know there are better ways to setup a cluster, but for now I just need to ensure the system remains operational as setup.

CodePudding user response:

From the doc:

  1. select pg_is_in_recovery();
  2. select pg_walfile_name(pg_last_wal_replay_lsn());
  3. Either that or select pg_current_wal_lsn(); on the primary, then select pg_wal_lsn_diff(pg_current_wal_lsn__taken_from_primary,pg_last_wal_replay_lsn()); on standby as commented by @Laurenz Albe.
  • Related