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

Commitff4220e

Browse files
author
Amit Kapila
committed
Attach FPI to the first record after full_page_writes is turned on.
XLogInsert fails to attach a required FPI to the first record afterfull_page_writes is turned on by the last checkpoint. This bug gotintroduced in 9.5 due to code rearrangement in commits2c03216 and2076db2. Fix it by ensuring that XLogInsertRecord performs arecomputation when the given record is generated with FPW as off butfound that the flag has been turned on while actually inserting therecord.Reported-by: Kyotaro HoriguchiAuthor: Kyotaro HoriguchiReviewed-by: Amit KapilaBackpatch-through: 9.5 where this problem was introducedDiscussion:https://postgr.es/m/20180420.151043.74298611.horiguchi.kyotaro@lab.ntt.co.jp
1 parent12368f5 commitff4220e

File tree

1 file changed

+13
-6
lines changed
  • src/backend/access/transam

1 file changed

+13
-6
lines changed

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ static void WALInsertLockUpdateInsertingAt(XLogRecPtr insertingAt);
943943
*
944944
* If 'fpw_lsn' is valid, it is the oldest LSN among the pages that this
945945
* WAL record applies to, that were not included in the record as full page
946-
* images. If fpw_lsn>= RedoRecPtr, the function does not perform the
946+
* images. If fpw_lsn<= RedoRecPtr, the function does not perform the
947947
* insertion and returns InvalidXLogRecPtr. The caller can then recalculate
948948
* which pages need a full-page image, and retry. If fpw_lsn is invalid, the
949949
* record is always inserted.
@@ -976,6 +976,7 @@ XLogInsertRecord(XLogRecData *rdata,
976976
info==XLOG_SWITCH);
977977
XLogRecPtrStartPos;
978978
XLogRecPtrEndPos;
979+
boolprevDoPageWrites=doPageWrites;
979980

980981
/* we assume that all of the record header is in the first chunk */
981982
Assert(rdata->len >=SizeOfXLogRecord);
@@ -1023,10 +1024,14 @@ XLogInsertRecord(XLogRecData *rdata,
10231024
WALInsertLockAcquire();
10241025

10251026
/*
1026-
* Check to see if my copy of RedoRecPtr or doPageWrites is out of date.
1027-
* If so, may have to go back and have the caller recompute everything.
1028-
* This can only happen just after a checkpoint, so it's better to be slow
1029-
* in this case and fast otherwise.
1027+
* Check to see if my copy of RedoRecPtr is out of date. If so, may have
1028+
* to go back and have the caller recompute everything. This can only
1029+
* happen just after a checkpoint, so it's better to be slow in this case
1030+
* and fast otherwise.
1031+
*
1032+
* Also check to see if fullPageWrites or forcePageWrites was just turned
1033+
* on; if we weren't already doing full-page writes then go back and
1034+
* recompute.
10301035
*
10311036
* If we aren't doing full-page writes then RedoRecPtr doesn't actually
10321037
* affect the contents of the XLOG record, so we'll update our local copy
@@ -1041,7 +1046,9 @@ XLogInsertRecord(XLogRecData *rdata,
10411046
}
10421047
doPageWrites= (Insert->fullPageWrites||Insert->forcePageWrites);
10431048

1044-
if (fpw_lsn!=InvalidXLogRecPtr&&fpw_lsn <=RedoRecPtr&&doPageWrites)
1049+
if (doPageWrites&&
1050+
(!prevDoPageWrites||
1051+
(fpw_lsn!=InvalidXLogRecPtr&&fpw_lsn <=RedoRecPtr)))
10451052
{
10461053
/*
10471054
* Oops, some buffer now needs to be backed up that the caller didn't

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp