Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit820ddb2

Browse files
committed
Further tweak commit_timestamp behavior
As pointed out by Fujii Masao, we weren't quite there on a standbybehaving sanely: first because we were failing to acquire the correctstate in the case where no XLOG_PARAMETER_CHANGE message was sent(because a checkpoint had already happened after the setting was changedin the master, and then the standby was restarted); and second becausepromoting the standby with the feature enabled failed to activate it ifthe master had the feature disabled.This patch fixes both those misbehaviors hopefully withoutre-introducing any old problems.Also change the hint emitted in a standby together with the errormessage about the feature being disabled, to make it point out that theplace to chance the setting is the master. Otherwise, if the setting isalready enabled in the standby, it is very confusing to have it say thatthe setting must be enabled ...Authors: Álvaro Herrera, Petr Jelínek.Backpatch to 9.5.
1 parent344cdff commit820ddb2

File tree

3 files changed

+25
-15
lines changed

3 files changed

+25
-15
lines changed

‎src/backend/access/transam/commit_ts.c

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ static void SetXidCommitTsInPage(TransactionId xid, int nsubxids,
106106
RepOriginIdnodeid,intpageno);
107107
staticvoidTransactionIdSetCommitTs(TransactionIdxid,TimestampTzts,
108108
RepOriginIdnodeid,intslotno);
109+
staticvoiderror_commit_ts_disabled(void);
109110
staticintZeroCommitTsPage(intpageno,boolwriteXlog);
110111
staticboolCommitTsPagePrecedes(intpage1,intpage2);
111112
staticvoidActivateCommitTs(void);
@@ -297,11 +298,7 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
297298

298299
/* Error if module not enabled */
299300
if (!commitTsShared->commitTsActive)
300-
ereport(ERROR,
301-
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
302-
errmsg("could not get commit timestamp data"),
303-
errhint("Make sure the configuration parameter \"%s\" is set.",
304-
"track_commit_timestamp")));
301+
error_commit_ts_disabled();
305302

306303
/*
307304
* If we're asked for the cached value, return that. Otherwise, fall
@@ -368,11 +365,7 @@ GetLatestCommitTsData(TimestampTz *ts, RepOriginId *nodeid)
368365

369366
/* Error if module not enabled */
370367
if (!commitTsShared->commitTsActive)
371-
ereport(ERROR,
372-
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
373-
errmsg("could not get commit timestamp data"),
374-
errhint("Make sure the configuration parameter \"%s\" is set.",
375-
"track_commit_timestamp")));
368+
error_commit_ts_disabled();
376369

377370
xid=commitTsShared->xidLastCommit;
378371
if (ts)
@@ -384,6 +377,19 @@ GetLatestCommitTsData(TimestampTz *ts, RepOriginId *nodeid)
384377
returnxid;
385378
}
386379

380+
staticvoid
381+
error_commit_ts_disabled(void)
382+
{
383+
ereport(ERROR,
384+
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
385+
errmsg("could not get commit timestamp data"),
386+
RecoveryInProgress() ?
387+
errhint("Make sure the configuration parameter \"%s\" is set in the master server.",
388+
"track_commit_timestamp") :
389+
errhint("Make sure the configuration parameter \"%s\" is set.",
390+
"track_commit_timestamp")));
391+
}
392+
387393
/*
388394
* SQL-callable wrapper to obtain commit time of a transaction
389395
*/
@@ -510,7 +516,7 @@ BootStrapCommitTs(void)
510516
/*
511517
* Nothing to do here at present, unlike most other SLRU modules; segments
512518
* are created when the server is started with this module enabled. See
513-
*StartupCommitTs.
519+
*ActivateCommitTs.
514520
*/
515521
}
516522

@@ -544,13 +550,13 @@ ZeroCommitTsPage(int pageno, bool writeXlog)
544550
* configuration.
545551
*/
546552
void
547-
StartupCommitTs(boolforce_enable)
553+
StartupCommitTs(boolenabled)
548554
{
549555
/*
550556
* If the module is not enabled, there's nothing to do here. The module
551557
* could still be activated from elsewhere.
552558
*/
553-
if (track_commit_timestamp||force_enable)
559+
if (enabled)
554560
ActivateCommitTs();
555561
}
556562

‎src/backend/access/transam/xlog.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6568,6 +6568,10 @@ StartupXLOG(void)
65686568
* Startup commit log, commit timestamp and subtrans only.
65696569
* MultiXact has already been started up and other SLRUs are not
65706570
* maintained during recovery and need not be started yet.
6571+
*
6572+
* For commit timestamps, we do this based on the control file
6573+
* info: in a standby, we want to drive it off the state of the
6574+
* master, not local configuration.
65716575
*/
65726576
StartupCLOG();
65736577
StartupCommitTs(ControlFile->track_commit_timestamp);
@@ -7339,7 +7343,7 @@ StartupXLOG(void)
73397343
if (standbyState==STANDBY_DISABLED)
73407344
{
73417345
StartupCLOG();
7342-
StartupCommitTs(false);
7346+
StartupCommitTs(track_commit_timestamp);
73437347
StartupSUBTRANS(oldestActiveXID);
73447348
}
73457349

‎src/include/access/commit_ts.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ extern Size CommitTsShmemBuffers(void);
3434
externSizeCommitTsShmemSize(void);
3535
externvoidCommitTsShmemInit(void);
3636
externvoidBootStrapCommitTs(void);
37-
externvoidStartupCommitTs(boolforce_enable);
37+
externvoidStartupCommitTs(boolenabled);
3838
externvoidCommitTsParameterChange(boolxlrecvalue,boolpgcontrolvalue);
3939
externvoidCompleteCommitTsInitialization(void);
4040
externvoidShutdownCommitTs(void);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp