mirror of
https://github.com/postgres/postgres.git
synced 2025-06-05 23:56:58 +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
5f1de60564
commit
a1fb84990d
@ -1195,6 +1195,9 @@ InitWalSenderSlot(void)
|
||||
*/
|
||||
walsnd->pid = MyProcPid;
|
||||
walsnd->sentPtr = InvalidXLogRecPtr;
|
||||
walsnd->write = InvalidXLogRecPtr;
|
||||
walsnd->flush = InvalidXLogRecPtr;
|
||||
walsnd->apply = InvalidXLogRecPtr;
|
||||
walsnd->state = WALSNDSTATE_STARTUP;
|
||||
SpinLockRelease(&walsnd->mutex);
|
||||
/* don't need the lock anymore */
|
||||
@ -1994,19 +1997,19 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS)
|
||||
(uint32) (sentPtr >> 32), (uint32) sentPtr);
|
||||
values[2] = CStringGetTextDatum(location);
|
||||
|
||||
if (write == 0)
|
||||
if (XLogRecPtrIsInvalid(write))
|
||||
nulls[3] = true;
|
||||
snprintf(location, sizeof(location), "%X/%X",
|
||||
(uint32) (write >> 32), (uint32) write);
|
||||
values[3] = CStringGetTextDatum(location);
|
||||
|
||||
if (flush == 0)
|
||||
if (XLogRecPtrIsInvalid(flush))
|
||||
nulls[4] = true;
|
||||
snprintf(location, sizeof(location), "%X/%X",
|
||||
(uint32) (flush >> 32), (uint32) flush);
|
||||
values[4] = CStringGetTextDatum(location);
|
||||
|
||||
if (apply == 0)
|
||||
if (XLogRecPtrIsInvalid(apply))
|
||||
nulls[5] = true;
|
||||
snprintf(location, sizeof(location), "%X/%X",
|
||||
(uint32) (apply >> 32), (uint32) apply);
|
||||
|
Loading…
x
Reference in New Issue
Block a user