Skip to content

Commit 598f303

Browse files
committed
Fix bogus time printout in walreceiver's debug log messages.
The displayed sendtime and receipttime were always exactly equal, because somebody forgot that timestamptz_to_str returns a static buffer (thereby simplifying life for most callers, at the cost of complicating it for those who need two results concurrently). Apply the same pstrdup solution used by the other call sites with this issue. Back-patch to 9.2 where the faulty code was introduced. Per bug #9849 from Haruka Takatsuka, though this is not exactly his patch. Possibly we should change timestamptz_to_str's API, but I wouldn't want to do so in the back branches.
1 parent a2f9572 commit 598f303

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/backend/replication/walreceiver.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,9 +1196,19 @@ ProcessWalSndrMessage(XLogRecPtr walEnd, TimestampTz sendTime)
11961196
SpinLockRelease(&walrcv->mutex);
11971197

11981198
if (log_min_messages <= DEBUG2)
1199+
{
1200+
char *sendtime;
1201+
char *receipttime;
1202+
1203+
/* Copy because timestamptz_to_str returns a static buffer */
1204+
sendtime = pstrdup(timestamptz_to_str(sendTime));
1205+
receipttime = pstrdup(timestamptz_to_str(lastMsgReceiptTime));
11991206
elog(DEBUG2, "sendtime %s receipttime %s replication apply delay %d ms transfer latency %d ms",
1200-
timestamptz_to_str(sendTime),
1201-
timestamptz_to_str(lastMsgReceiptTime),
1207+
sendtime,
1208+
receipttime,
12021209
GetReplicationApplyDelay(),
12031210
GetReplicationTransferLatency());
1211+
pfree(sendtime);
1212+
pfree(receipttime);
1213+
}
12041214
}

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