diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 969d1c6c46..d7505aa454 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -9272,6 +9272,7 @@ void UpdateFullPageWrites(void) { XLogCtlInsert *Insert = &XLogCtl->Insert; + bool recoveryInProgress; /* * Do nothing if full_page_writes has not been changed. @@ -9283,6 +9284,13 @@ UpdateFullPageWrites(void) if (fullPageWrites == Insert->fullPageWrites) return; + /* + * Perform this outside critical section so that the WAL insert + * initialization done by RecoveryInProgress() doesn't trigger an + * assertion failure. + */ + recoveryInProgress = RecoveryInProgress(); + START_CRIT_SECTION(); /* @@ -9303,7 +9311,7 @@ UpdateFullPageWrites(void) * Write an XLOG_FPW_CHANGE record. This allows us to keep track of * full_page_writes during archive recovery, if required. */ - if (XLogStandbyInfoActive() && !RecoveryInProgress()) + if (XLogStandbyInfoActive() && !recoveryInProgress) { XLogBeginInsert(); XLogRegisterData((char *) (&fullPageWrites), sizeof(bool));