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

Commitf8409b3

Browse files
Fix timing of Startup CLOG and MultiXact during Hot Standby
Patch by me, bug report by Chris Redekop, analysis by Florian Pflug
1 parentc2891b4 commitf8409b3

File tree

5 files changed

+34
-6
lines changed

5 files changed

+34
-6
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,25 @@ StartupCLOG(void)
489489
*/
490490
ClogCtl->shared->latest_page_number=pageno;
491491

492+
LWLockRelease(CLogControlLock);
493+
}
494+
495+
/*
496+
* This must be called ONCE at the end of startup/recovery.
497+
*/
498+
void
499+
TrimCLOG(void)
500+
{
501+
TransactionIdxid=ShmemVariableCache->nextXid;
502+
intpageno=TransactionIdToPage(xid);
503+
504+
LWLockAcquire(CLogControlLock,LW_EXCLUSIVE);
505+
506+
/*
507+
* Re-Initialize our idea of the latest page number.
508+
*/
509+
ClogCtl->shared->latest_page_number=pageno;
510+
492511
/*
493512
* Zero out the remainder of the current clog page. Under normal
494513
* circumstances it should be zeroes already, but it seems at least

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1567,7 +1567,7 @@ StartupMultiXact(void)
15671567

15681568
/*
15691569
* Zero out the remainder of the current members page.See notes in
1570-
*StartupCLOG() for motivation.
1570+
*TrimCLOG() for motivation.
15711571
*/
15721572
entryno=MXOffsetToMemberEntry(offset);
15731573
if (entryno!=0)

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6410,10 +6410,12 @@ StartupXLOG(void)
64106410
oldestActiveXID=checkPoint.oldestActiveXid;
64116411
Assert(TransactionIdIsValid(oldestActiveXID));
64126412

6413-
/* Startup commit log and related stuff */
6413+
/*
6414+
* Startup commit log and subtrans only. Other SLRUs are not
6415+
* maintained during recovery and need not be started yet.
6416+
*/
64146417
StartupCLOG();
64156418
StartupSUBTRANS(oldestActiveXID);
6416-
StartupMultiXact();
64176419

64186420
/*
64196421
* If we're beginning at a shutdown checkpoint, we know that
@@ -6914,16 +6916,21 @@ StartupXLOG(void)
69146916
TransactionIdRetreat(ShmemVariableCache->latestCompletedXid);
69156917

69166918
/*
6917-
* Start up the commit log andrelated stuff, too. In hot standby mode we
6918-
*did this already before WAL replay.
6919+
* Start up the commit log andsubtrans, if not already done for
6920+
*hot standby.
69196921
*/
69206922
if (standbyState==STANDBY_DISABLED)
69216923
{
69226924
StartupCLOG();
69236925
StartupSUBTRANS(oldestActiveXID);
6924-
StartupMultiXact();
69256926
}
69266927

6928+
/*
6929+
* Perform end of recovery actions for any SLRUs that need it.
6930+
*/
6931+
StartupMultiXact();
6932+
TrimCLOG();
6933+
69276934
/* Reload shared-memory state for prepared transactions */
69286935
RecoverPreparedTransactions();
69296936

‎src/backend/utils/init/postinit.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include"pgstat.h"
3737
#include"postmaster/autovacuum.h"
3838
#include"postmaster/postmaster.h"
39+
#include"postmaster/startup.h"
3940
#include"replication/walsender.h"
4041
#include"storage/bufmgr.h"
4142
#include"storage/fd.h"

‎src/include/access/clog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ extern Size CLOGShmemSize(void);
4040
externvoidCLOGShmemInit(void);
4141
externvoidBootStrapCLOG(void);
4242
externvoidStartupCLOG(void);
43+
externvoidTrimCLOG(void);
4344
externvoidShutdownCLOG(void);
4445
externvoidCheckPointCLOG(void);
4546
externvoidExtendCLOG(TransactionIdnewestXact);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp