]> granicus.if.org Git - postgresql/commitdiff
Prevent non-streaming replication connections from being selected sync slave
authorMagnus Hagander <magnus@hagander.net>
Mon, 11 Jun 2012 13:07:55 +0000 (15:07 +0200)
committerMagnus Hagander <magnus@hagander.net>
Mon, 11 Jun 2012 13:17:38 +0000 (15:17 +0200)
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

src/backend/replication/syncrep.c

index a2ae8700d12a9cd1603a6775aa94385743a9a302..a3319642c628e99aef7c5cf55b40d2ddb907bbe5 100644 (file)
@@ -397,6 +397,7 @@ SyncRepReleaseWaiters(void)
                volatile WalSnd *walsnd = &walsndctl->walsnds[i];
 
                if (walsnd->pid != 0 &&
+                       walsnd->state == WALSNDSTATE_STREAMING &&
                        walsnd->sync_standby_priority > 0 &&
                        (priority == 0 ||
                         priority > walsnd->sync_standby_priority))