0

My goal is to let the master server still be able to process write request while standby is in failure. I have noticed synchronous_commit = can be manually set to off and then reload the primary server.

Other configuration includes repmgr.conf for repmgr: use_replication_slots=yes

Therefore the standby server created by repmgr request the primary server to reserve wal-logs for it while it is in failure. Things goes not exactly as expected - I am able to commit writing operation to the primary and the standby is able to clone that from primary, but with a bug - the writing command always stuck here:

postgres=# CREATE DATABASE ANYTHING;

The prompt did not show up again until I pressed Ctrl+D, with these lines:

^CCancel request sent
WARNING:  canceling wait for synchronous replication due to user request
DETAIL:  The transaction has already committed locally, but might not have been replicated to the standby.
CREATE DATABASE
postgres=#

So it always ended up a freeze whenever I tried to write to the primary while its synchronous_commit = off. (psql -c ... will result in a freeze in shell too) This means this temporary change of replication setting does not reach my goal to prevent primary from a "strike" while standby encounters problem!

Is there a way to get around this freeze? Thanks.

George Y
  • 528
  • 6
  • 16
  • Which Postgres version? If you want to stop synchronous replication temporary *remove the setting* `synchronous_standby_names` (set to empty, the default) in the configuration file and then reload the server. Set it back when standby is ready again (make sure slot retains all the WAL logs for it to catch up, otherwise you'd need to recreate it from scratch). `synchronous_commit` is per-session variable; you shouldn't need to restart server but you have to set it into your session prior to performing transactions. – Nikita Kipriyanov Aug 31 '23 at 09:12
  • @Nikita Kipriyanov Thanks for the reply. It is version 15. So the configuration I set in `repmgr`: `use_replication_slots=yes` is essential here? The default behavior for `repmgr` however is `no` use of replication slots. – George Y Aug 31 '23 at 10:04
  • It's not essential *here* but it will make your life easier. What is essential is that if you use slots you *have* to monitor your pg_wal directory size; it will grow if slots aren't consumed and can potentially overflow. But this is not the topic of the question. – Nikita Kipriyanov Aug 31 '23 at 10:27

0 Answers0