aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2014-04-04 11:43:41 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2014-04-04 11:43:41 -0400
commited1cb4241585efe86d45edfed9eaf1995aa5421f (patch)
tree9b4977f12f6dbbb1afa9e6f2f4f0563be522787b /src
parent7d1e0e8d7a96ac2be5c3ce0e68a5c4eb65fccff2 (diff)
downloadpostgresql-ed1cb4241585efe86d45edfed9eaf1995aa5421f.tar.gz
postgresql-ed1cb4241585efe86d45edfed9eaf1995aa5421f.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/backend/replication/walreceiver.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 7a0102d694b..88e65d9501c 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -767,9 +767,19 @@ ProcessWalSndrMessage(XLogRecPtr walEnd, TimestampTz sendTime)
SpinLockRelease(&walrcv->mutex);
if (log_min_messages <= DEBUG2)
+ {
+ char *sendtime;
+ char *receipttime;
+
+ /* Copy because timestamptz_to_str returns a static buffer */
+ sendtime = pstrdup(timestamptz_to_str(sendTime));
+ receipttime = pstrdup(timestamptz_to_str(lastMsgReceiptTime));
elog(DEBUG2, "sendtime %s receipttime %s replication apply delay %d ms transfer latency %d ms",
- timestamptz_to_str(sendTime),
- timestamptz_to_str(lastMsgReceiptTime),
+ sendtime,
+ receipttime,
GetReplicationApplyDelay(),
GetReplicationTransferLatency());
+ pfree(sendtime);
+ pfree(receipttime);
+ }
}