Commit 3595a71e authored by Magnus Hagander's avatar Magnus Hagander

Prevent non-streaming replication connections from being selected sync slave

This prevents a pg_basebackup backup session that just does a base
backup (no xlog involved at all) from becoming the synchronous slave
and thus blocking all access while it runs.

Also fixes the problem when a higher priority slave shows up it would
become the sync standby before it has reached the STREAMING state, by
making sure we can only switch to a walsender that's actually STREAMING.

Fujii Masao
parent 9af34cde
...@@ -397,6 +397,7 @@ SyncRepReleaseWaiters(void) ...@@ -397,6 +397,7 @@ SyncRepReleaseWaiters(void)
volatile WalSnd *walsnd = &walsndctl->walsnds[i]; volatile WalSnd *walsnd = &walsndctl->walsnds[i];
if (walsnd->pid != 0 && if (walsnd->pid != 0 &&
walsnd->state == WALSNDSTATE_STREAMING &&
walsnd->sync_standby_priority > 0 && walsnd->sync_standby_priority > 0 &&
(priority == 0 || (priority == 0 ||
priority > walsnd->sync_standby_priority)) priority > walsnd->sync_standby_priority))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment