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

Commit8340eba

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 parent63d8350 commit8340eba

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

‎src/backend/replication/syncrep.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -397,10 +397,12 @@ SyncRepReleaseWaiters(void)
397397
* If this WALSender is serving a standby that is not on the list of
398398
* potential sync standbys then we have nothing to do. If we are still
399399
* starting up, still running base backup or the current flush position is
400-
* still invalid, then leave quickly also.
400+
* still invalid, then leave quickly also. Streaming or stopping WAL
401+
* senders are allowed to release waiters.
401402
*/
402403
if (MyWalSnd->sync_standby_priority==0||
403-
MyWalSnd->state<WALSNDSTATE_STREAMING||
404+
(MyWalSnd->state!=WALSNDSTATE_STREAMING&&
405+
MyWalSnd->state!=WALSNDSTATE_STOPPING)||
404406
XLogRecPtrIsInvalid(MyWalSnd->flush))
405407
{
406408
announce_next_takeover= true;
@@ -585,8 +587,9 @@ SyncRepGetSyncStandbys(bool *am_sync)
585587
if (walsnd->pid==0)
586588
continue;
587589

588-
/* Must be streaming */
589-
if (walsnd->state!=WALSNDSTATE_STREAMING)
590+
/* Must be streaming or stopping */
591+
if (walsnd->state!=WALSNDSTATE_STREAMING&&
592+
walsnd->state!=WALSNDSTATE_STOPPING)
590593
continue;
591594

592595
/* Must be synchronous */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp