Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4c70336

Browse files
committed
Fix handling of synchronous replication for stopping WAL senders
This fixes an oversight fromc6c3334 which forgot that if a subset ofWAL senders are stopping and in a sync state, other WAL senders couldstill be waiting for a WAL position to be synced while committing atransaction. However the subset of stopping senders would not releasewaiters, potentially breaking synchronous replication guarantees. Thiscommit makes sure that even WAL senders stopping are able to releasewaiters and are tracked properly.On 9.4, this can also trigger an assertion failure when setting forexample max_wal_senders to 1 where a WAL sender is not able to finditself as in synchronous state when the instance stops.Reported-by: Paul GuoAuthor: Paul Guo, Michael PaquierDiscussion:https://postgr.es/m/CAEET0ZEv8VFqT3C-cQm6byOB4r4VYWcef1J21dOX-gcVhCSpmA@mail.gmail.comBackpatch-through: 9.4
1 parent1a990b2 commit4c70336

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

‎src/backend/replication/syncrep.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -425,10 +425,12 @@ SyncRepReleaseWaiters(void)
425425
* If this WALSender is serving a standby that is not on the list of
426426
* potential sync standbys then we have nothing to do. If we are still
427427
* starting up, still running base backup or the current flush position is
428-
* still invalid, then leave quickly also.
428+
* still invalid, then leave quickly also. Streaming or stopping WAL
429+
* senders are allowed to release waiters.
429430
*/
430431
if (MyWalSnd->sync_standby_priority==0||
431-
MyWalSnd->state<WALSNDSTATE_STREAMING||
432+
(MyWalSnd->state!=WALSNDSTATE_STREAMING&&
433+
MyWalSnd->state!=WALSNDSTATE_STOPPING)||
432434
XLogRecPtrIsInvalid(MyWalSnd->flush))
433435
{
434436
announce_next_takeover= true;
@@ -730,8 +732,9 @@ SyncRepGetSyncStandbysQuorum(bool *am_sync)
730732
if (pid==0)
731733
continue;
732734

733-
/* Must be streaming */
734-
if (state!=WALSNDSTATE_STREAMING)
735+
/* Must be streaming or stopping */
736+
if (state!=WALSNDSTATE_STREAMING&&
737+
state!=WALSNDSTATE_STOPPING)
735738
continue;
736739

737740
/* Must be synchronous */
@@ -809,8 +812,9 @@ SyncRepGetSyncStandbysPriority(bool *am_sync)
809812
if (pid==0)
810813
continue;
811814

812-
/* Must be streaming */
813-
if (state!=WALSNDSTATE_STREAMING)
815+
/* Must be streaming or stopping */
816+
if (state!=WALSNDSTATE_STREAMING&&
817+
state!=WALSNDSTATE_STOPPING)
814818
continue;
815819

816820
/* Must be synchronous */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp