summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/replication/syncrep.c9
-rw-r--r--src/backend/replication/walsender.c6
2 files changed, 10 insertions, 5 deletions
diff --git a/src/backend/replication/syncrep.c b/src/backend/replication/syncrep.c
index caf16efa168..651525f59f5 100644
--- a/src/backend/replication/syncrep.c
+++ b/src/backend/replication/syncrep.c
@@ -379,10 +379,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;
@@ -400,7 +402,8 @@ SyncRepReleaseWaiters(void)
volatile WalSnd *walsnd = &walsndctl->walsnds[i];
if (walsnd->pid != 0 &&
- walsnd->state == WALSNDSTATE_STREAMING &&
+ (walsnd->state == WALSNDSTATE_STREAMING ||
+ walsnd->state == WALSNDSTATE_STOPPING) &&
walsnd->sync_standby_priority > 0 &&
(priority == 0 ||
priority > walsnd->sync_standby_priority) &&
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 4c7d55488ed..2e944a93905 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2941,12 +2941,14 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS)
/*
* Treat a standby such as a pg_basebackup background process
* which always returns an invalid flush location, as an
- * asynchronous standby.
+ * asynchronous standby. WAL sender must be streaming or
+ * stopping.
*/
sync_priority[i] = XLogRecPtrIsInvalid(walsnd->flush) ?
0 : walsnd->sync_standby_priority;
- if (walsnd->state == WALSNDSTATE_STREAMING &&
+ if ((walsnd->state == WALSNDSTATE_STREAMING ||
+ walsnd->state == WALSNDSTATE_STOPPING) &&
walsnd->sync_standby_priority > 0 &&
(priority == 0 ||
priority > walsnd->sync_standby_priority) &&