postgres.git / summary / log / commit / refs
commit 306b9918b2dd2fb93ea5a0fb62904a05c73fd87a
Author: Heikki Linnakangas <heikki.linnakangas@iki.fi>
Date: Fri Dec 19 15:00:21 2014 +0000
First released in: 9.5.0, 9.3.6, 9.4.1
Fix timestamp in end-of-recovery WAL records.
We used time(null) to set a TimestampTz field, which gave bogus results.
Noticed while looking at pg_xlogdump output.
Backpatch to 9.3 and above, where the fast promotion was introduced.
src/backend/access/transam/xlog.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index b2443c082e8..b44aec46cf7 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -8408,7 +8408,7 @@ CreateEndOfRecoveryRecord(void)
if (!RecoveryInProgress())
elog(ERROR, "can only be used to end recovery");
- xlrec.end_time = time(NULL);
+ xlrec.end_time = GetCurrentTimestamp();
WALInsertLockAcquireExclusive();
xlrec.ThisTimeLineID = ThisTimeLineID;
@@ -8433,7 +8433,7 @@ CreateEndOfRecoveryRecord(void)
* changes to this point.
*/
LWLockAcquire(ControlFileLock, LW_EXCLUSIVE);
- ControlFile->time = (pg_time_t) xlrec.end_time;
+ ControlFile->time = (pg_time_t) time(NULL);
ControlFile->minRecoveryPoint = recptr;
ControlFile->minRecoveryPointTLI = ThisTimeLineID;
UpdateControlFile();
[parent: 4c853646ae06]