Answer the question
In order to leave comments, you need to log in
Postgres synchronous replication?
Good afternoon.
PostgreSQL has synchronous replication via the setting synchronous_commit = on ( https://postgrespro.ru/docs/postgrespro/12/runtime... on the master.
Raised 1 master node and 2 slaves. Set up replication correctly postgres says that both slaves work through synchronous replication.
To check, I wrote a script that inserts into the master and then extracts data from two slaves.
For the test, I insert 1000 records in a row. When searching for them in the slaves, sometimes it does not find all the records. For example, it finds 998 out of 1000 inserted. If you add a small delay, then all records are found stably.
With synchronous_commit = on, the master must wait for confirmation that the data has been saved to disk from each synchronous slave, and only then respond to the client about a successful insert.
Maybe someone faced a similar problem?
The task is to put a master node for writing, and all read requests must process synchronous replicas, but the problem of not found records casts doubt on such a bundle.
For the test, I raised it in containers and asked questions on github. Perhaps a more detailed description of the problem will be there https://github.com/bitnami/bitnami-docker-postgres...
Answer the question
In order to leave comments, you need to log in
Moment one: what synchronous_standby_names?
Second moment:
replication via setting synchronous_commit = on
When set to on, commits will wait until replies from the current synchronous standby(s) indicate they have received the commit record of the transaction and flushed it to disk.
When set to remote_apply, commits will wait until replies from the current synchronous standby(s) indicate they have received the commit record of the transaction and applied it , so that it has become visible to queries on the standby(s).
master node for writing, and all read requests must process synchronous replicas
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question