Content-Length: 268900 | pFad | http://github.com/postgres/postgres/commit/87be749c716a5d58ca0a92a56f0c1b7ba8e1fae4

AE Use replay LSN as target for cascading logical WAL senders · postgres/postgres@87be749 · GitHub
Skip to content

Commit 87be749

Browse files
committed
Use replay LSN as target for cascading logical WAL senders
A cascading WAL sender doing logical decoding (as known as doing its work on a standby) has been using as flush LSN the value returned by GetStandbyFlushRecPtr() (last position safely flushed to disk). This is incorrect as such processes are only able to decode changes up to the LSN 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 important particularly during shutdown, when WAL senders need to send any remaining available data to their clients, switching WAL senders to a caught-up state. Using the latest flush LSN rather than the replay LSN could cause the WAL senders to be stuck in an infinite loop preventing them to shut down, as the startup process does not run when WAL senders attempt to catch up, so they could keep waiting for work that would never happen. Backpatch down to v16, where logical decoding on standbys has been introduced. 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.ru Backpatch-through: 16
1 parent 6f724fc commit 87be749

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
@@ -3450,8 +3450,16 @@ XLogSendLogical(void)
34503450
if (flushPtr == InvalidXLogRecPtr ||
34513451
logical_decoding_ctx->reader->EndRecPtr >= flushPtr)
34523452
{
3453+
/*
3454+
* For cascading logical WAL senders, we use the replay LSN instead of
3455+
* the flush LSN, since logical decoding on a standby only processes
3456+
* WAL that has been replayed. This distinction becomes particularly
3457+
* important during shutdown, as new WAL is no longer replayed and the
3458+
* last replayed LSN marks the furthest point up to which decoding can
3459+
* proceed.
3460+
*/
34533461
if (am_cascading_walsender)
3454-
flushPtr = GetStandbyFlushRecPtr(NULL);
3462+
flushPtr = GetXLogReplayRecPtr(NULL);
34553463
else
34563464
flushPtr = GetFlushRecPtr(NULL);
34573465
}

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgres/postgres/commit/87be749c716a5d58ca0a92a56f0c1b7ba8e1fae4

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy