@@ -276,8 +276,8 @@ XLogRecPtr XactLastCommitEnd = InvalidXLogRecPtr;
276
276
static XLogRecPtr RedoRecPtr ;
277
277
278
278
/*
279
- * doPageWrites is this backend's local copy of (forcePageWrites ||
280
- * fullPageWrites ). It is used together with RedoRecPtr to decide whether
279
+ * doPageWrites is this backend's local copy of (fullPageWrites ||
280
+ * runningBackups > 0 ). It is used together with RedoRecPtr to decide whether
281
281
* a full-page image of a page need to be taken.
282
282
*
283
283
* NB: Initially this is false, and there's no guarantee that it will be
@@ -437,14 +437,12 @@ typedef struct XLogCtlInsert
437
437
* you must hold ALL the locks.
438
438
*/
439
439
XLogRecPtr RedoRecPtr ; /* current redo point for insertions */
440
- bool forcePageWrites ; /* forcing full-page writes for PITR? */
441
440
bool fullPageWrites ;
442
441
443
442
/*
444
443
* runningBackups is a counter indicating the number of backups currently
445
- * in progress. forcePageWrites is set to true when runningBackups is
446
- * non-zero. lastBackupStart is the latest checkpoint redo location used
447
- * as a starting point for an online backup.
444
+ * in progress. lastBackupStart is the latest checkpoint redo location
445
+ * used as a starting point for an online backup.
448
446
*/
449
447
int runningBackups ;
450
448
XLogRecPtr lastBackupStart ;
@@ -805,9 +803,9 @@ XLogInsertRecord(XLogRecData *rdata,
805
803
* happen just after a checkpoint, so it's better to be slow in this case
806
804
* and fast otherwise.
807
805
*
808
- * Also check to see if fullPageWrites or forcePageWrites was just turned
809
- * on; if we weren't already doing full-page writes then go back and
810
- * recompute.
806
+ * Also check to see if fullPageWrites was just turned on or there's a
807
+ * running backup (which forces full-page writes); if we weren't already
808
+ * doing full-page writes then go back and recompute.
811
809
*
812
810
* If we aren't doing full-page writes then RedoRecPtr doesn't actually
813
811
* affect the contents of the XLOG record, so we'll update our local copy
@@ -820,7 +818,7 @@ XLogInsertRecord(XLogRecData *rdata,
820
818
Assert (RedoRecPtr < Insert -> RedoRecPtr );
821
819
RedoRecPtr = Insert -> RedoRecPtr ;
822
820
}
823
- doPageWrites = (Insert -> fullPageWrites || Insert -> forcePageWrites );
821
+ doPageWrites = (Insert -> fullPageWrites || Insert -> runningBackups > 0 );
824
822
825
823
if (doPageWrites &&
826
824
(!prevDoPageWrites ||
@@ -1899,7 +1897,7 @@ AdvanceXLInsertBuffer(XLogRecPtr upto, TimeLineID tli, bool opportunistic)
1899
1897
* is unsafe, but at worst the archiver would miss the opportunity to
1900
1898
* compress a few records.
1901
1899
*/
1902
- if (! Insert -> forcePageWrites )
1900
+ if (Insert -> runningBackups == 0 )
1903
1901
NewPage -> xlp_info |= XLP_BKP_REMOVABLE ;
1904
1902
1905
1903
/*
@@ -8299,29 +8297,28 @@ do_pg_backup_start(const char *backupidstr, bool fast, List **tablespaces,
8299
8297
* written) copy of a database page if it reads the page concurrently with
8300
8298
* our write to the same page. This can be fixed as long as the first
8301
8299
* write to the page in the WAL sequence is a full-page write. Hence, we
8302
- * turn on forcePageWrites and then force a CHECKPOINT, to ensure there
8303
- * are no dirty pages in shared memory that might get dumped while the
8304
- * backup is in progress without having a corresponding WAL record. (Once
8305
- * the backup is complete, we need not force full-page writes anymore,
8306
- * since we expect that any pages not modified during the backup interval
8307
- * must have been correctly captured by the backup.)
8300
+ * increment runningBackups then force a CHECKPOINT, to ensure there are
8301
+ * no dirty pages in shared memory that might get dumped while the backup
8302
+ * is in progress without having a corresponding WAL record. (Once the
8303
+ * backup is complete, we need not force full-page writes anymore, since
8304
+ * we expect that any pages not modified during the backup interval must
8305
+ * have been correctly captured by the backup.)
8308
8306
*
8309
- * Note that forcePageWrites has no effect during an online backup from
8310
- * the standby.
8307
+ * Note that forcing full-page writes has no effect during an online
8308
+ * backup from the standby.
8311
8309
*
8312
8310
* We must hold all the insertion locks to change the value of
8313
- * forcePageWrites , to ensure adequate interlocking against
8311
+ * runningBackups , to ensure adequate interlocking against
8314
8312
* XLogInsertRecord().
8315
8313
*/
8316
8314
WALInsertLockAcquireExclusive ();
8317
8315
XLogCtl -> Insert .runningBackups ++ ;
8318
- XLogCtl -> Insert .forcePageWrites = true;
8319
8316
WALInsertLockRelease ();
8320
8317
8321
8318
/*
8322
- * Ensure we release forcePageWrites if fail below. NB -- for this to work
8323
- * correctly, it is critical that sessionBackupState is only updated after
8324
- * this block is over.
8319
+ * Ensure we decrement runningBackups if we fail below. NB -- for this to
8320
+ * work correctly, it is critical that sessionBackupState is only updated
8321
+ * after this block is over.
8325
8322
*/
8326
8323
PG_ENSURE_ERROR_CLEANUP (do_pg_abort_backup , DatumGetBool (true));
8327
8324
{
@@ -8593,10 +8590,10 @@ do_pg_backup_stop(BackupState *state, bool waitforarchive)
8593
8590
errhint ("wal_level must be set to \"replica\" or \"logical\" at server start." )));
8594
8591
8595
8592
/*
8596
- * OK to update backup counters, forcePageWrites, and session-level lock.
8593
+ * OK to update backup counter and session-level lock.
8597
8594
*
8598
- * Note that CHECK_FOR_INTERRUPTS() must not occur while updating them.
8599
- * Otherwise they can be updated inconsistently, and which might cause
8595
+ * Note that CHECK_FOR_INTERRUPTS() must not occur while updating them,
8596
+ * otherwise they can be updated inconsistently, which might cause
8600
8597
* do_pg_abort_backup() to fail.
8601
8598
*/
8602
8599
WALInsertLockAcquireExclusive ();
@@ -8608,11 +8605,6 @@ do_pg_backup_stop(BackupState *state, bool waitforarchive)
8608
8605
Assert (XLogCtl -> Insert .runningBackups > 0 );
8609
8606
XLogCtl -> Insert .runningBackups -- ;
8610
8607
8611
- if (XLogCtl -> Insert .runningBackups == 0 )
8612
- {
8613
- XLogCtl -> Insert .forcePageWrites = false;
8614
- }
8615
-
8616
8608
/*
8617
8609
* Clean up session-level lock.
8618
8610
*
@@ -8859,11 +8851,6 @@ do_pg_abort_backup(int code, Datum arg)
8859
8851
Assert (XLogCtl -> Insert .runningBackups > 0 );
8860
8852
XLogCtl -> Insert .runningBackups -- ;
8861
8853
8862
- if (XLogCtl -> Insert .runningBackups == 0 )
8863
- {
8864
- XLogCtl -> Insert .forcePageWrites = false;
8865
- }
8866
-
8867
8854
sessionBackupState = SESSION_BACKUP_NONE ;
8868
8855
WALInsertLockRelease ();
8869
8856
0 commit comments