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

Commit3114cb6

Browse files
committed
Don't advance checkPoint.nextXid near the end of a checkpoint sequence.
This reverts commitc111306 in favor ofactually fixing the problem: namely, that we should never have beenmodifying the checkpoint record's nextXid at this point to begin with.The nextXid should match the state as of the checkpoint's logical WALposition (ie the redo point), not the state as of its physical position.It's especially bogus to advance it in some wal_levels and not others.In any case there is no need for the checkpoint record to carry thesame nextXid shown in the XLOG_RUNNING_XACTS record just emitted byLogStandbySnapshot, as any replay operation will already have adoptedthat value as current.This fixes bug #7710 from Tarvi Pillessaar, and probably also explains bug#6291 from Daniel Farina, in that if a checkpoint were in progress at theinstant of XID wraparound, the epoch bump would be lost as reported.(And, of course, these days there's at least a 50-50 chance of a checkpointbeing in progress at any given instant.)Diagnosed by me and independently by Andres Freund. Back-patch to allbranches supporting hot standby.
1 parent5c11725 commit3114cb6

File tree

3 files changed

+3
-14
lines changed

3 files changed

+3
-14
lines changed

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7119,18 +7119,9 @@ CreateCheckPoint(int flags)
71197119
*
71207120
* If we are shutting down, or Startup process is completing crash
71217121
* recovery we don't need to write running xact data.
7122-
*
7123-
* Update checkPoint.nextXid since we may have a later value. If we
7124-
* do update the value, and we have wrapped, increment epoch also.
71257122
*/
71267123
if (!shutdown&&XLogStandbyInfoActive())
7127-
{
7128-
TransactionIdprevXid=checkPoint.nextXid;
7129-
7130-
LogStandbySnapshot(&checkPoint.nextXid);
7131-
if (checkPoint.nextXid<prevXid)
7132-
checkPoint.nextXidEpoch++;
7133-
}
7124+
LogStandbySnapshot();
71347125

71357126
START_CRIT_SECTION();
71367127

‎src/backend/storage/ipc/standby.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ standby_redo(XLogRecPtr lsn, XLogRecord *record)
848848
* from a time when they were possible.
849849
*/
850850
void
851-
LogStandbySnapshot(TransactionId*nextXid)
851+
LogStandbySnapshot(void)
852852
{
853853
RunningTransactionsrunning;
854854
xl_standby_lock*locks;
@@ -877,8 +877,6 @@ LogStandbySnapshot(TransactionId *nextXid)
877877
LogCurrentRunningXacts(running);
878878
/* GetRunningTransactionData() acquired XidGenLock, we must release it */
879879
LWLockRelease(XidGenLock);
880-
881-
*nextXid=running->nextXid;
882880
}
883881

884882
/*

‎src/include/storage/standby.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,6 @@ typedef RunningTransactionsData *RunningTransactions;
113113
externvoidLogAccessExclusiveLock(OiddbOid,OidrelOid);
114114
externvoidLogAccessExclusiveLockPrepare(void);
115115

116-
externvoidLogStandbySnapshot(TransactionId*nextXid);
116+
externvoidLogStandbySnapshot(void);
117117

118118
#endif/* STANDBY_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp