Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@sgotti
Copy link
Member

@sgotti sgotti commented Dec 6, 2016

Currently synchronous replication just sets all the standbys as
synchronous_standby_names. So postgres will choose one of them as the
synchronous standby. If this fails, another will be automicatally
choosen by postgres. So currently stolon has no way to be sure which standby
was the current synchronous one when the master died and just uses the
last reported state to find the best one.

This patch makes synchronous replication more strict and fixes this
problem.

Now the sentinel define only the synchronous standbys in
synchronous_standby_names.

For postgresql < 9.5 this will be only one, with postgresql >= 9.6 there
can be more than one.

If there're not enough available standbys then it will also add a fake
standby server. Adding a non existing standby server will ensure the
master will always block waiting for remote commits.

In this way the sentinel always know which was the latest synchronous
standby avoiding any data loss caused by choosing a non synchronous
standby. If both the master and the sync standby dies at the same time
it won't elect another non sync standby.

@sgotti sgotti force-pushed the strict_sync_repl branch 2 times, most recently from 28543f6 to 40446b1 Compare December 7, 2016 15:38
Currently synchronous replication just sets all the standbys as
`synchronous_standby_names`. So postgres will choose one of them as the
synchronous standby. If this fails, another will be automicatally
choosen by postgres. So currently stolon has no way to be sure which standby
was the current synchronous one when the master died and just uses the
last reported state to find the best one.

This patch makes synchronous replication more strict and fixes this
problem.

Now the sentinel define only the synchronous standbys in
`synchronous_standby_names`.

For postgresql < 9.5 this will be only one, with postgresql >= 9.6 there
can be more than one.

If there're not enough available standbys then it will also add a fake
standby server. Adding a non existing standby server will ensure the
master will always block waiting for remote commits.

In this way the sentinel always know which was the latest synchronous
standby avoiding any data loss caused by choosing a non synchronous
standby. If both the master and the sync standby dies at the same time
it won't elect another non sync standby.
@sgotti sgotti merged commit 1cca095 into sorintlab:master Dec 8, 2016
sgotti added a commit that referenced this pull request Dec 8, 2016
stolon: implement strict synchronous replication
@sgotti sgotti modified the milestone: v0.5.0 Dec 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant