aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2014-04-04 11:43:34 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2014-04-04 11:44:04 -0400
commit8120c7452a51a773ad7a249b55557439f39d41ef (patch)
tree665f91cbc1af645774e0ca1bfefcbdad4ad882a4 /src
parent59202fae0434c98beb4994c5fe4df354a6af31e6 (diff)
downloadpostgresql-8120c7452a51a773ad7a249b55557439f39d41ef.tar.gz
postgresql-8120c7452a51a773ad7a249b55557439f39d41ef.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 43db10851c3..b0de0ea253e 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1199,9 +1199,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);
+ }
}