Commit 5c805d0a authored by Heikki Linnakangas's avatar Heikki Linnakangas

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.
parent 37de8de9
...@@ -8076,7 +8076,7 @@ CreateEndOfRecoveryRecord(void) ...@@ -8076,7 +8076,7 @@ CreateEndOfRecoveryRecord(void)
if (!RecoveryInProgress()) if (!RecoveryInProgress())
elog(ERROR, "can only be used to end recovery"); elog(ERROR, "can only be used to end recovery");
xlrec.end_time = time(NULL); xlrec.end_time = GetCurrentTimestamp();
WALInsertLockAcquireExclusive(); WALInsertLockAcquireExclusive();
xlrec.ThisTimeLineID = ThisTimeLineID; xlrec.ThisTimeLineID = ThisTimeLineID;
...@@ -8098,7 +8098,7 @@ CreateEndOfRecoveryRecord(void) ...@@ -8098,7 +8098,7 @@ CreateEndOfRecoveryRecord(void)
* changes to this point. * changes to this point.
*/ */
LWLockAcquire(ControlFileLock, LW_EXCLUSIVE); LWLockAcquire(ControlFileLock, LW_EXCLUSIVE);
ControlFile->time = (pg_time_t) xlrec.end_time; ControlFile->time = (pg_time_t) time(NULL);
ControlFile->minRecoveryPoint = recptr; ControlFile->minRecoveryPoint = recptr;
ControlFile->minRecoveryPointTLI = ThisTimeLineID; ControlFile->minRecoveryPointTLI = ThisTimeLineID;
UpdateControlFile(); UpdateControlFile();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment