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

Commit18e0913

Browse files
committed
StartupXLOG: Don't repeatedly disable/enable local xlog insertion.
All the code that runs in the startup process to write WAL recordsbefore that's allowed generally is now consecutive, so there's noreason to shut the facility to write WAL locally off and then turnit on again three times in a row.Unfortunately, this requires a slight kludge in the checkpointer,which needs to separately enable writing WAL in order to write thecheckpoint record. Because that code might run in the same processas StartupXLOG() if we are in single-user mode, we must save/restorethe state of the LocalXLogInsertAllowed flag. Hopefully, we'll beable to eliminate this wart in further refactoring, but it'snot too bad anyway.Amul Sul, with modifications by me.Discussion:http://postgr.es/m/CAAJ_b97fysj6sRSQEfOHj-y8Jfd5uPqOgO74qast89B4WfD+TA@mail.gmail.com
1 parenta75dbf7 commit18e0913

File tree

1 file changed

+12
-11
lines changed
  • src/backend/access/transam

1 file changed

+12
-11
lines changed

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ static void checkTimeLineSwitch(XLogRecPtr lsn, TimeLineID newTLI,
905905
TimeLineIDprevTLI);
906906
staticvoidVerifyOverwriteContrecord(xl_overwrite_contrecord*xlrec,
907907
XLogReaderState*state);
908-
staticvoidLocalSetXLogInsertAllowed(void);
908+
staticintLocalSetXLogInsertAllowed(void);
909909
staticvoidCreateEndOfRecoveryRecord(void);
910910
staticXLogRecPtrCreateOverwriteContrecordRecord(XLogRecPtraborted_lsn);
911911
staticvoidCheckPointGuts(XLogRecPtrcheckPointRedo,intflags);
@@ -8062,6 +8062,7 @@ StartupXLOG(void)
80628062
}
80638063
XLogReaderFree(xlogreader);
80648064

8065+
/* Enable WAL writes for this backend only. */
80658066
LocalSetXLogInsertAllowed();
80668067

80678068
/* If necessary, write overwrite-contrecord before doing anything else */
@@ -8080,7 +8081,6 @@ StartupXLOG(void)
80808081
*/
80818082
Insert->fullPageWrites=lastFullPageWrites;
80828083
UpdateFullPageWrites();
8083-
LocalXLogInsertAllowed=-1;
80848084

80858085
/*
80868086
* Emit checkpoint or end-of-recovery record in XLOG, if required.
@@ -8098,7 +8098,6 @@ StartupXLOG(void)
80988098
* If any of the critical GUCs have changed, log them before we allow
80998099
* backends to write WAL.
81008100
*/
8101-
LocalSetXLogInsertAllowed();
81028101
XLogReportParameters();
81038102

81048103
/* If this is archive recovery, perform post-recovery cleanup actions. */
@@ -8467,15 +8466,20 @@ XLogInsertAllowed(void)
84678466
*
84688467
* Note: it is allowed to switch LocalXLogInsertAllowed back to -1 later,
84698468
* and even call LocalSetXLogInsertAllowed() again after that.
8469+
*
8470+
* Returns the previous value of LocalXLogInsertAllowed.
84708471
*/
8471-
staticvoid
8472+
staticint
84728473
LocalSetXLogInsertAllowed(void)
84738474
{
8474-
Assert(LocalXLogInsertAllowed==-1);
8475+
intoldXLogAllowed=LocalXLogInsertAllowed;
8476+
84758477
LocalXLogInsertAllowed=1;
84768478

84778479
/* Initialize as RecoveryInProgress() would do when switching state */
84788480
InitXLOGAccess();
8481+
8482+
returnoldXLogAllowed;
84798483
}
84808484

84818485
/*
@@ -9020,6 +9024,7 @@ CreateCheckPoint(int flags)
90209024
XLogRecPtrlast_important_lsn;
90219025
VirtualTransactionId*vxids;
90229026
intnvxids;
9027+
intoldXLogAllowed;
90239028

90249029
/*
90259030
* An end-of-recovery checkpoint is really a shutdown checkpoint, just
@@ -9127,7 +9132,7 @@ CreateCheckPoint(int flags)
91279132
* initialized, which we need here and in AdvanceXLInsertBuffer.)
91289133
*/
91299134
if (flags&CHECKPOINT_END_OF_RECOVERY)
9130-
LocalSetXLogInsertAllowed();
9135+
oldXLogAllowed=LocalSetXLogInsertAllowed();
91319136

91329137
checkPoint.ThisTimeLineID=ThisTimeLineID;
91339138
if (flags&CHECKPOINT_END_OF_RECOVERY)
@@ -9307,7 +9312,7 @@ CreateCheckPoint(int flags)
93079312
if (shutdown)
93089313
{
93099314
if (flags&CHECKPOINT_END_OF_RECOVERY)
9310-
LocalXLogInsertAllowed=-1;/* return to "check" state */
9315+
LocalXLogInsertAllowed=oldXLogAllowed;
93119316
else
93129317
LocalXLogInsertAllowed=0;/* never again write WAL */
93139318
}
@@ -9447,8 +9452,6 @@ CreateEndOfRecoveryRecord(void)
94479452
xlrec.PrevTimeLineID=XLogCtl->PrevTimeLineID;
94489453
WALInsertLockRelease();
94499454

9450-
LocalSetXLogInsertAllowed();
9451-
94529455
START_CRIT_SECTION();
94539456

94549457
XLogBeginInsert();
@@ -9469,8 +9472,6 @@ CreateEndOfRecoveryRecord(void)
94699472
LWLockRelease(ControlFileLock);
94709473

94719474
END_CRIT_SECTION();
9472-
9473-
LocalXLogInsertAllowed=-1;/* return to "check" state */
94749475
}
94759476

94769477
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp