Content-Length: 268874 | pFad | http://github.com/postgres/postgres/commit/5e6d561bc14db260e7456e02f7a15f46b0302f58

82 Use replay LSN as target for cascading logical WAL senders · postgres/postgres@5e6d561 · GitHub
Skip to content

Commit 5e6d561

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 ecc8fd2 commit 5e6d561

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
@@ -3119,8 +3119,16 @@ XLogSendLogical(void)
31193119
if (flushPtr == InvalidXLogRecPtr ||
31203120
logical_decoding_ctx->reader->EndRecPtr >= flushPtr)
31213121
{
3122+
/*
3123+
* For cascading logical WAL senders, we use the replay LSN instead of
3124+
* the flush LSN, since logical decoding on a standby only processes
3125+
* WAL that has been replayed. This distinction becomes particularly
3126+
* important during shutdown, as new WAL is no longer replayed and the
3127+
* last replayed LSN marks the furthest point up to which decoding can
3128+
* proceed.
3129+
*/
31223130
if (am_cascading_walsender)
3123-
flushPtr = GetStandbyFlushRecPtr(NULL);
3131+
flushPtr = GetXLogReplayRecPtr(NULL);
31243132
else
31253133
flushPtr = GetFlushRecPtr(NULL);
31263134
}

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/5e6d561bc14db260e7456e02f7a15f46b0302f58

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy