Skip to content

Commit a86bf60

Browse files
author
Amit Kapila
committed
Fix assertion failure when updating full_page_writes for checkpointer.
When the checkpointer receives a SIGHUP signal to update its configuration, it may need to update the shared memory for full_page_writes and need to write a WAL record for it. Now, it is quite possible that the XLOG machinery has not been initialized by that time and it will lead to assertion failure while doing that. Fix is to allow the initialization of the XLOG machinery outside critical section. This bug has been introduced by the commit 2c03216 which added the XLOG machinery initialization in RecoveryInProgress code path. Reported-by: Dilip Kumar Author: Dilip Kumar Reviewed-by: Michael Paquier and Amit Kapila Backpatch-through: 9.5 Discussion: https://postgr.es/m/CAFiTN-u4BA8KXcQUWDPNgaKAjDXC=C2whnzBM8TAcv=stckYUw@mail.gmail.com
1 parent 92a0342 commit a86bf60

File tree

1 file changed

+9
-1
lines changed
  • src/backend/access/transam

1 file changed

+9
-1
lines changed

src/backend/access/transam/xlog.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9701,6 +9701,7 @@ void
97019701
UpdateFullPageWrites(void)
97029702
{
97039703
XLogCtlInsert *Insert = &XLogCtl->Insert;
9704+
bool recoveryInProgress;
97049705

97059706
/*
97069707
* Do nothing if full_page_writes has not been changed.
@@ -9712,6 +9713,13 @@ UpdateFullPageWrites(void)
97129713
if (fullPageWrites == Insert->fullPageWrites)
97139714
return;
97149715

9716+
/*
9717+
* Perform this outside critical section so that the WAL insert
9718+
* initialization done by RecoveryInProgress() doesn't trigger an
9719+
* assertion failure.
9720+
*/
9721+
recoveryInProgress = RecoveryInProgress();
9722+
97159723
START_CRIT_SECTION();
97169724

97179725
/*
@@ -9732,7 +9740,7 @@ UpdateFullPageWrites(void)
97329740
* Write an XLOG_FPW_CHANGE record. This allows us to keep track of
97339741
* full_page_writes during archive recovery, if required.
97349742
*/
9735-
if (XLogStandbyInfoActive() && !RecoveryInProgress())
9743+
if (XLogStandbyInfoActive() && !recoveryInProgress)
97369744
{
97379745
XLogBeginInsert();
97389746
XLogRegisterData((char *) (&fullPageWrites), sizeof(bool));

0 commit comments

Comments
 (0)