Skip to content

Commit 61c7bee

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 6bdef13 commit 61c7bee

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
@@ -1957,6 +1957,9 @@ InitWalSenderSlot(void)
19571957
*/
19581958
walsnd->pid = MyProcPid;
19591959
walsnd->sentPtr = InvalidXLogRecPtr;
1960+
walsnd->write = InvalidXLogRecPtr;
1961+
walsnd->flush = InvalidXLogRecPtr;
1962+
walsnd->apply = InvalidXLogRecPtr;
19601963
walsnd->state = WALSNDSTATE_STARTUP;
19611964
SpinLockRelease(&walsnd->mutex);
19621965
/* don't need the lock anymore */
@@ -2843,15 +2846,15 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS)
28432846
values[1] = CStringGetTextDatum(WalSndGetStateString(state));
28442847
values[2] = LSNGetDatum(sentPtr);
28452848

2846-
if (write == 0)
2849+
if (XLogRecPtrIsInvalid(write))
28472850
nulls[3] = true;
28482851
values[3] = LSNGetDatum(write);
28492852

2850-
if (flush == 0)
2853+
if (XLogRecPtrIsInvalid(flush))
28512854
nulls[4] = true;
28522855
values[4] = LSNGetDatum(flush);
28532856

2854-
if (apply == 0)
2857+
if (XLogRecPtrIsInvalid(apply))
28552858
nulls[5] = true;
28562859
values[5] = LSNGetDatum(apply);
28572860

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