mirror of
https://github.com/postgres/postgres.git
synced 2025-05-05 09:19:17 +03:00
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.
This commit is contained in:
parent
332be65b5e
commit
a9c56ff0e1
@ -1960,6 +1960,9 @@ InitWalSenderSlot(void)
|
|||||||
*/
|
*/
|
||||||
walsnd->pid = MyProcPid;
|
walsnd->pid = MyProcPid;
|
||||||
walsnd->sentPtr = InvalidXLogRecPtr;
|
walsnd->sentPtr = InvalidXLogRecPtr;
|
||||||
|
walsnd->write = InvalidXLogRecPtr;
|
||||||
|
walsnd->flush = InvalidXLogRecPtr;
|
||||||
|
walsnd->apply = InvalidXLogRecPtr;
|
||||||
walsnd->state = WALSNDSTATE_STARTUP;
|
walsnd->state = WALSNDSTATE_STARTUP;
|
||||||
walsnd->latch = &MyProc->procLatch;
|
walsnd->latch = &MyProc->procLatch;
|
||||||
SpinLockRelease(&walsnd->mutex);
|
SpinLockRelease(&walsnd->mutex);
|
||||||
@ -2825,15 +2828,15 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS)
|
|||||||
values[1] = CStringGetTextDatum(WalSndGetStateString(state));
|
values[1] = CStringGetTextDatum(WalSndGetStateString(state));
|
||||||
values[2] = LSNGetDatum(sentPtr);
|
values[2] = LSNGetDatum(sentPtr);
|
||||||
|
|
||||||
if (write == 0)
|
if (XLogRecPtrIsInvalid(write))
|
||||||
nulls[3] = true;
|
nulls[3] = true;
|
||||||
values[3] = LSNGetDatum(write);
|
values[3] = LSNGetDatum(write);
|
||||||
|
|
||||||
if (flush == 0)
|
if (XLogRecPtrIsInvalid(flush))
|
||||||
nulls[4] = true;
|
nulls[4] = true;
|
||||||
values[4] = LSNGetDatum(flush);
|
values[4] = LSNGetDatum(flush);
|
||||||
|
|
||||||
if (apply == 0)
|
if (XLogRecPtrIsInvalid(apply))
|
||||||
nulls[5] = true;
|
nulls[5] = true;
|
||||||
values[5] = LSNGetDatum(apply);
|
values[5] = LSNGetDatum(apply);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user