aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xlog.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/access/transam/xlog.c')
-rw-r--r--src/backend/access/transam/xlog.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 651b0f3a84d..9b7a47fdfe8 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -939,7 +939,7 @@ static void WALInsertLockUpdateInsertingAt(XLogRecPtr insertingAt);
*
* If 'fpw_lsn' is valid, it is the oldest LSN among the pages that this
* WAL record applies to, that were not included in the record as full page
- * images. If fpw_lsn >= RedoRecPtr, the function does not perform the
+ * images. If fpw_lsn <= RedoRecPtr, the function does not perform the
* insertion and returns InvalidXLogRecPtr. The caller can then recalculate
* which pages need a full-page image, and retry. If fpw_lsn is invalid, the
* record is always inserted.
@@ -972,6 +972,7 @@ XLogInsertRecord(XLogRecData *rdata,
info == XLOG_SWITCH);
XLogRecPtr StartPos;
XLogRecPtr EndPos;
+ bool prevDoPageWrites = doPageWrites;
/* we assume that all of the record header is in the first chunk */
Assert(rdata->len >= SizeOfXLogRecord);
@@ -1019,10 +1020,14 @@ XLogInsertRecord(XLogRecData *rdata,
WALInsertLockAcquire();
/*
- * Check to see if my copy of RedoRecPtr or doPageWrites is out of date.
- * If so, may have to go back and have the caller recompute everything.
- * This can only happen just after a checkpoint, so it's better to be slow
- * in this case and fast otherwise.
+ * Check to see if my copy of RedoRecPtr is out of date. If so, may have
+ * to go back and have the caller recompute everything. This can only
+ * happen just after a checkpoint, so it's better to be slow in this case
+ * and fast otherwise.
+ *
+ * Also check to see if fullPageWrites or forcePageWrites was just turned
+ * on; if we weren't already doing full-page writes then go back and
+ * recompute.
*
* If we aren't doing full-page writes then RedoRecPtr doesn't actually
* affect the contents of the XLOG record, so we'll update our local copy
@@ -1037,7 +1042,9 @@ XLogInsertRecord(XLogRecData *rdata,
}
doPageWrites = (Insert->fullPageWrites || Insert->forcePageWrites);
- if (fpw_lsn != InvalidXLogRecPtr && fpw_lsn <= RedoRecPtr && doPageWrites)
+ if (doPageWrites &&
+ (!prevDoPageWrites ||
+ (fpw_lsn != InvalidXLogRecPtr && fpw_lsn <= RedoRecPtr)))
{
/*
* Oops, some buffer now needs to be backed up that the caller didn't