aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xlog.c
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2015-10-01 15:06:55 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2015-10-01 15:06:55 -0300
commitf12e814b88d8082804bbc8b827469d8068e7252c (patch)
treefdf8dabf89b96942b45c40cde58d0ac1cb2f6b9a /src/backend/access/transam/xlog.c
parentbf4817e4f090a0a72d1849a3d61b45e7f2feadda (diff)
downloadpostgresql-f12e814b88d8082804bbc8b827469d8068e7252c.tar.gz
postgresql-f12e814b88d8082804bbc8b827469d8068e7252c.zip
Fix commit_ts for standby
Module initialization was still not completely correct after commit 6b61955135e9, per crash report from Takashi Ohnishi. To fix, instead of trying to monkey around with the value of the GUC setting directly, add a separate boolean flag that enables the feature on a standby, but only for the startup (recovery) process, when it sees that its master server has the feature enabled. Discussion: http://www.postgresql.org/message-id/ca44c6c7f9314868bdc521aea4f77cbf@MP-MSGSS-MBX004.msg.nttdata.co.jp Also change the deactivation routine to delete all segment files rather than leaving the last one around. (This doesn't need separate WAL-logging, because on recovery we execute the same deactivation routine anyway.) In passing, clean up the code structure somewhat, particularly so that xlog.c doesn't know so much about when to activate/deactivate the feature. Thanks to Fujii Masao for testing and Petr JelĂ­nek for off-list discussion. Back-patch to 9.5, where commit_ts was introduced.
Diffstat (limited to 'src/backend/access/transam/xlog.c')
-rw-r--r--src/backend/access/transam/xlog.c26
1 files changed, 5 insertions, 21 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 0266d61bbdb..08d16823ed1 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -6567,7 +6567,7 @@ StartupXLOG(void)
* maintained during recovery and need not be started yet.
*/
StartupCLOG();
- StartupCommitTs();
+ StartupCommitTs(ControlFile->track_commit_timestamp);
StartupSUBTRANS(oldestActiveXID);
/*
@@ -7336,7 +7336,7 @@ StartupXLOG(void)
if (standbyState == STANDBY_DISABLED)
{
StartupCLOG();
- StartupCommitTs();
+ StartupCommitTs(false);
StartupSUBTRANS(oldestActiveXID);
}
@@ -9456,25 +9456,9 @@ xlog_redo(XLogReaderState *record)
ControlFile->minRecoveryPointTLI = ThisTimeLineID;
}
- /*
- * Update the commit timestamp tracking. If there was a change it
- * needs to be activated or deactivated accordingly.
- */
- if (track_commit_timestamp != xlrec.track_commit_timestamp)
- {
- track_commit_timestamp = xlrec.track_commit_timestamp;
- ControlFile->track_commit_timestamp = track_commit_timestamp;
- if (track_commit_timestamp)
- ActivateCommitTs();
- else
-
- /*
- * We can't create a new WAL record here, but that's OK as
- * master did the WAL logging already and we will replay the
- * record from master in case we crash.
- */
- DeactivateCommitTs(false);
- }
+ CommitTsParameterChange(xlrec.track_commit_timestamp,
+ ControlFile->track_commit_timestamp);
+ ControlFile->track_commit_timestamp = xlrec.track_commit_timestamp;
UpdateControlFile();
LWLockRelease(ControlFileLock);