Don't open a WAL segment for writing at end of recovery.
Since commitba94518a
, we used XLogFileOpen to open the next segment for writing, but if the end-of-recovery happens exactly at a segment boundary, the new segment might not exist yet. (Beforeba94518a
, XLogFileOpen was correct, because we would open the previous segment if the switch happened at the boundary.) Instead of trying to create it if necessary, it's simpler to not bother opening the segment at all. XLogWrite() will open or create it soon anyway, after writing the checkpoint or end-of-recovery record. Reported by Andres Freund.
This commit is contained in:
parent
79af9a1d26
commit
1e78d81e88
|
@ -5646,7 +5646,6 @@ StartupXLOG(void)
|
||||||
XLogRecPtr RecPtr,
|
XLogRecPtr RecPtr,
|
||||||
checkPointLoc,
|
checkPointLoc,
|
||||||
EndOfLog;
|
EndOfLog;
|
||||||
XLogSegNo startLogSegNo;
|
|
||||||
TimeLineID PrevTimeLineID;
|
TimeLineID PrevTimeLineID;
|
||||||
XLogRecord *record;
|
XLogRecord *record;
|
||||||
TransactionId oldestActiveXID;
|
TransactionId oldestActiveXID;
|
||||||
|
@ -6633,7 +6632,6 @@ StartupXLOG(void)
|
||||||
*/
|
*/
|
||||||
record = ReadRecord(xlogreader, LastRec, PANIC, false);
|
record = ReadRecord(xlogreader, LastRec, PANIC, false);
|
||||||
EndOfLog = EndRecPtr;
|
EndOfLog = EndRecPtr;
|
||||||
XLByteToSeg(EndOfLog, startLogSegNo);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Complain if we did not roll forward far enough to render the backup
|
* Complain if we did not roll forward far enough to render the backup
|
||||||
|
@ -6741,9 +6739,6 @@ StartupXLOG(void)
|
||||||
* buffer cache using the block containing the last record from the
|
* buffer cache using the block containing the last record from the
|
||||||
* previous incarnation.
|
* previous incarnation.
|
||||||
*/
|
*/
|
||||||
openLogSegNo = startLogSegNo;
|
|
||||||
openLogFile = XLogFileOpen(openLogSegNo);
|
|
||||||
openLogOff = 0;
|
|
||||||
Insert = &XLogCtl->Insert;
|
Insert = &XLogCtl->Insert;
|
||||||
Insert->PrevBytePos = XLogRecPtrToBytePos(LastRec);
|
Insert->PrevBytePos = XLogRecPtrToBytePos(LastRec);
|
||||||
Insert->CurrBytePos = XLogRecPtrToBytePos(EndOfLog);
|
Insert->CurrBytePos = XLogRecPtrToBytePos(EndOfLog);
|
||||||
|
|
Loading…
Reference in New Issue