aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/replication/syncrep.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/backend/replication/syncrep.c b/src/backend/replication/syncrep.c
index ea6ffc0f315..08588bfcb04 100644
--- a/src/backend/replication/syncrep.c
+++ b/src/backend/replication/syncrep.c
@@ -366,8 +366,9 @@ SyncRepGetSynchronousStandby(void)
if (walsnd->pid == 0)
continue;
- /* Must be streaming */
- if (walsnd->state != WALSNDSTATE_STREAMING)
+ /* Must be streaming or stopping */
+ if (walsnd->state != WALSNDSTATE_STREAMING &&
+ walsnd->state != WALSNDSTATE_STOPPING)
continue;
/* Must be synchronous */
@@ -416,10 +417,12 @@ SyncRepReleaseWaiters(void)
* If this WALSender is serving a standby that is not on the list of
* potential sync standbys then we have nothing to do. If we are still
* starting up, still running base backup or the current flush position
- * is still invalid, then leave quickly also.
+ * is still invalid, then leave quickly also. Streaming or stopping WAL
+ * senders are allowed to release waiters.
*/
if (MyWalSnd->sync_standby_priority == 0 ||
- MyWalSnd->state < WALSNDSTATE_STREAMING ||
+ (MyWalSnd->state != WALSNDSTATE_STREAMING &&
+ MyWalSnd->state != WALSNDSTATE_STOPPING) ||
XLogRecPtrIsInvalid(MyWalSnd->flush))
return;