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

Commit5231ed8

Browse files
committed
Use replay LSN as target for cascading logical WAL senders
A cascading WAL sender doing logical decoding (as known as doing itswork on a standby) has been using as flush LSN the value returned byGetStandbyFlushRecPtr() (last position safely flushed to disk). This isincorrect as such processes are only able to decode changes up to theLSN that has been replayed by the startup process.This commit changes cascading logical WAL senders to use the replay LSN,as returned by GetXLogReplayRecPtr(). This distinction is importantparticularly during shutdown, when WAL senders need to send anyremaining available data to their clients, switching WAL senders to acaught-up state. Using the latest flush LSN rather than the replay LSNcould cause the WAL senders to be stuck in an infinite loop preventingthem to shut down, as the startup process does not run when WAL sendersattempt to catch up, so they could keep waiting for work that wouldnever happen.Backpatch down to v16, where logical decoding on standbys has beenintroduced.Author: Alexey Makhmutov <a.makhmutov@postgrespro.ru>Reviewed-by: Ajin Cherian <itsajin@gmail.com>Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>Reviewed-by: Michael Paquier <michael@paquier.xyz>Discussion:https://postgr.es/m/52138028-7246-421c-9161-4fa108b88070@postgrespro.ruBackpatch-through: 16
1 parentc98975b commit5231ed8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

‎src/backend/replication/walsender.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3449,8 +3449,16 @@ XLogSendLogical(void)
34493449
if (flushPtr==InvalidXLogRecPtr||
34503450
logical_decoding_ctx->reader->EndRecPtr >=flushPtr)
34513451
{
3452+
/*
3453+
* For cascading logical WAL senders, we use the replay LSN instead of
3454+
* the flush LSN, since logical decoding on a standby only processes
3455+
* WAL that has been replayed. This distinction becomes particularly
3456+
* important during shutdown, as new WAL is no longer replayed and the
3457+
* last replayed LSN marks the furthest point up to which decoding can
3458+
* proceed.
3459+
*/
34523460
if (am_cascading_walsender)
3453-
flushPtr=GetStandbyFlushRecPtr(NULL);
3461+
flushPtr=GetXLogReplayRecPtr(NULL);
34543462
else
34553463
flushPtr=GetFlushRecPtr(NULL);
34563464
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp