summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Hagander <magnus@hagander.net>2015-12-13 16:40:37 +0100
committerMagnus Hagander <magnus@hagander.net>2015-12-13 16:44:04 +0100
commita1fb84990dc172f21f12a8fb79ab58876e81fe6b (patch)
treed213d4221d6eaccfea0f8c12d73a2f4123845aa2
parent5f1de605640578667e97894d846d119a5dc5a31f (diff)
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.
-rw-r--r--src/backend/replication/walsender.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 50cb0048d6b..9b455eef585 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -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);