diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2015-12-11 14:30:43 -0300 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2015-12-11 14:30:43 -0300 |
commit | 0f2c089d3423bcf2bb11d1e5d2d38638cc31fec4 (patch) | |
tree | 585fe90094ec19eb71ecefe7ec941ea195df1875 /src/backend/access/transam/xlog.c | |
parent | 0fc7c4a557752652ebddddb55ad11228129b530e (diff) | |
download | postgresql-0f2c089d3423bcf2bb11d1e5d2d38638cc31fec4.tar.gz postgresql-0f2c089d3423bcf2bb11d1e5d2d38638cc31fec4.zip |
Fix commit timestamp initialization
This module needs explicit initialization in order to replay WAL records
in recovery, but we had broken this recently following changes to make
other (stranger) scenarios work correctly. To fix, rework the
initialization sequence so that it always takes place before WAL replay
commences for both master and standby.
I could have gone for a more localized fix that just added a "startup"
call for the master server, but it seemed better to restructure the
existing callers as well so that the whole thing made more sense. As a
drawback, there is more control logic in xlog.c now than previously, but
doing otherwise meant passing down the ControlFile flag, which seemed
uglier as a whole.
This also meant adding a check to not re-execute ActivateCommitTs if it
had already been called.
Reported by Fujii Masao.
Backpatch to 9.5.
Diffstat (limited to 'src/backend/access/transam/xlog.c')
-rw-r--r-- | src/backend/access/transam/xlog.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 86debf44123..71fc8ffa272 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -6339,6 +6339,14 @@ StartupXLOG(void) StartupMultiXact(); /* + * Ditto commit timestamps. In a standby, we do it if setting is enabled + * in ControlFile; in a master we base the decision on the GUC itself. + */ + if (ArchiveRecoveryRequested ? + ControlFile->track_commit_timestamp : track_commit_timestamp) + StartupCommitTs(); + + /* * Recover knowledge about replay progress of known replication partners. */ StartupReplicationOrigin(); @@ -6565,16 +6573,11 @@ StartupXLOG(void) ProcArrayInitRecovery(ShmemVariableCache->nextXid); /* - * Startup commit log, commit timestamp and subtrans only. - * MultiXact has already been started up and other SLRUs are not + * Startup commit log and subtrans only. MultiXact and commit + * timestamp have already been started up and other SLRUs are not * maintained during recovery and need not be started yet. - * - * For commit timestamps, we do this based on the control file - * info: in a standby, we want to drive it off the state of the - * master, not local configuration. */ StartupCLOG(); - StartupCommitTs(ControlFile->track_commit_timestamp); StartupSUBTRANS(oldestActiveXID); /* @@ -7337,13 +7340,12 @@ StartupXLOG(void) LWLockRelease(ProcArrayLock); /* - * Start up the commit log, commit timestamp and subtrans, if not already - * done for hot standby. + * Start up the commit log and subtrans, if not already done for hot + * standby. (commit timestamps are started below, if necessary.) */ if (standbyState == STANDBY_DISABLED) { StartupCLOG(); - StartupCommitTs(track_commit_timestamp); StartupSUBTRANS(oldestActiveXID); } |