diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 5abaeb005b..7375a78ffc 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -9701,6 +9701,7 @@ void UpdateFullPageWrites(void) { XLogCtlInsert *Insert = &XLogCtl->Insert; + bool recoveryInProgress; /* * Do nothing if full_page_writes has not been changed. @@ -9712,6 +9713,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(); /* @@ -9732,7 +9740,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));