Skip to content

Commit a9c56ff

Browse files
committed
Properly initialize write, flush and replay locations in walsender slots
These would leak random xlog positions if a walsender used for backup would a walsender slot previously used by a replication walsender. In passing also fix a couple of cases where the xlog pointer is directly compared to zero instead of using XLogRecPtrIsInvalid, noted by Michael Paquier.
1 parent 332be65 commit a9c56ff

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/backend/replication/walsender.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1960,6 +1960,9 @@ InitWalSenderSlot(void)
19601960
*/
19611961
walsnd->pid = MyProcPid;
19621962
walsnd->sentPtr = InvalidXLogRecPtr;
1963+
walsnd->write = InvalidXLogRecPtr;
1964+
walsnd->flush = InvalidXLogRecPtr;
1965+
walsnd->apply = InvalidXLogRecPtr;
19631966
walsnd->state = WALSNDSTATE_STARTUP;
19641967
walsnd->latch = &MyProc->procLatch;
19651968
SpinLockRelease(&walsnd->mutex);
@@ -2825,15 +2828,15 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS)
28252828
values[1] = CStringGetTextDatum(WalSndGetStateString(state));
28262829
values[2] = LSNGetDatum(sentPtr);
28272830

2828-
if (write == 0)
2831+
if (XLogRecPtrIsInvalid(write))
28292832
nulls[3] = true;
28302833
values[3] = LSNGetDatum(write);
28312834

2832-
if (flush == 0)
2835+
if (XLogRecPtrIsInvalid(flush))
28332836
nulls[4] = true;
28342837
values[4] = LSNGetDatum(flush);
28352838

2836-
if (apply == 0)
2839+
if (XLogRecPtrIsInvalid(apply))
28372840
nulls[5] = true;
28382841
values[5] = LSNGetDatum(apply);
28392842

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy