]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix timestamp in end-of-recovery WAL records.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Fri, 19 Dec 2014 15:00:21 +0000 (17:00 +0200)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Fri, 19 Dec 2014 15:03:56 +0000 (17:03 +0200)
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

index e1fa0f28c36f770347e7d4abda84968d0f248ab6..7e05bdf7c7c97d217e2e6e7272c59c00206f0c9b 100644 (file)
@@ -7270,7 +7270,7 @@ CreateEndOfRecoveryRecord(void)
        if (!RecoveryInProgress())
                elog(ERROR, "can only be used to end recovery");
 
-       xlrec.end_time = time(NULL);
+       xlrec.end_time = GetCurrentTimestamp();
 
        LWLockAcquire(WALInsertLock, LW_SHARED);
        xlrec.ThisTimeLineID = ThisTimeLineID;
@@ -7295,7 +7295,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();