diff --git a/src/backend/replication/syncrep.c b/src/backend/replication/syncrep.c index 75d2681719..61256db467 100644 --- a/src/backend/replication/syncrep.c +++ b/src/backend/replication/syncrep.c @@ -423,10 +423,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. + * 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)) { announce_next_takeover = true; @@ -728,8 +730,9 @@ SyncRepGetSyncStandbysQuorum(bool *am_sync) if (pid == 0) continue; - /* Must be streaming */ - if (state != WALSNDSTATE_STREAMING) + /* Must be streaming or stopping */ + if (state != WALSNDSTATE_STREAMING && + state != WALSNDSTATE_STOPPING) continue; /* Must be synchronous */ @@ -807,8 +810,9 @@ SyncRepGetSyncStandbysPriority(bool *am_sync) if (pid == 0) continue; - /* Must be streaming */ - if (state != WALSNDSTATE_STREAMING) + /* Must be streaming or stopping */ + if (state != WALSNDSTATE_STREAMING && + state != WALSNDSTATE_STOPPING) continue; /* Must be synchronous */