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

Commitede7d81

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 parentaed0150 commitede7d81

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
@@ -939,7 +939,7 @@ static void WALInsertLockUpdateInsertingAt(XLogRecPtr insertingAt);
939939
*
940940
* If 'fpw_lsn' is valid, it is the oldest LSN among the pages that this
941941
* WAL record applies to, that were not included in the record as full page
942-
* images. If fpw_lsn>= RedoRecPtr, the function does not perform the
942+
* images. If fpw_lsn<= RedoRecPtr, the function does not perform the
943943
* insertion and returns InvalidXLogRecPtr. The caller can then recalculate
944944
* which pages need a full-page image, and retry. If fpw_lsn is invalid, the
945945
* record is always inserted.
@@ -972,6 +972,7 @@ XLogInsertRecord(XLogRecData *rdata,
972972
info==XLOG_SWITCH);
973973
XLogRecPtrStartPos;
974974
XLogRecPtrEndPos;
975+
boolprevDoPageWrites=doPageWrites;
975976

976977
/* we assume that all of the record header is in the first chunk */
977978
Assert(rdata->len >=SizeOfXLogRecord);
@@ -1019,10 +1020,14 @@ XLogInsertRecord(XLogRecData *rdata,
10191020
WALInsertLockAcquire();
10201021

10211022
/*
1022-
* Check to see if my copy of RedoRecPtr or doPageWrites is out of date.
1023-
* If so, may have to go back and have the caller recompute everything.
1024-
* This can only happen just after a checkpoint, so it's better to be slow
1025-
* in this case and fast otherwise.
1023+
* Check to see if my copy of RedoRecPtr is out of date. If so, may have
1024+
* to go back and have the caller recompute everything. This can only
1025+
* happen just after a checkpoint, so it's better to be slow in this case
1026+
* and fast otherwise.
1027+
*
1028+
* Also check to see if fullPageWrites or forcePageWrites was just turned
1029+
* on; if we weren't already doing full-page writes then go back and
1030+
* recompute.
10261031
*
10271032
* If we aren't doing full-page writes then RedoRecPtr doesn't actually
10281033
* affect the contents of the XLOG record, so we'll update our local copy
@@ -1037,7 +1042,9 @@ XLogInsertRecord(XLogRecData *rdata,
10371042
}
10381043
doPageWrites= (Insert->fullPageWrites||Insert->forcePageWrites);
10391044

1040-
if (fpw_lsn!=InvalidXLogRecPtr&&fpw_lsn <=RedoRecPtr&&doPageWrites)
1045+
if (doPageWrites&&
1046+
(!prevDoPageWrites||
1047+
(fpw_lsn!=InvalidXLogRecPtr&&fpw_lsn <=RedoRecPtr)))
10411048
{
10421049
/*
10431050
* Oops, some buffer now needs to be backed up that the caller didn't

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp