mirror of
https://github.com/postgres/postgres.git
synced 2025-05-12 16:21:30 +03:00
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 2c03216d83 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
This commit is contained in:
parent
f4fa92f267
commit
e315bd7db9
@ -9272,6 +9272,7 @@ void
|
|||||||
UpdateFullPageWrites(void)
|
UpdateFullPageWrites(void)
|
||||||
{
|
{
|
||||||
XLogCtlInsert *Insert = &XLogCtl->Insert;
|
XLogCtlInsert *Insert = &XLogCtl->Insert;
|
||||||
|
bool recoveryInProgress;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Do nothing if full_page_writes has not been changed.
|
* Do nothing if full_page_writes has not been changed.
|
||||||
@ -9283,6 +9284,13 @@ UpdateFullPageWrites(void)
|
|||||||
if (fullPageWrites == Insert->fullPageWrites)
|
if (fullPageWrites == Insert->fullPageWrites)
|
||||||
return;
|
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();
|
START_CRIT_SECTION();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -9303,7 +9311,7 @@ UpdateFullPageWrites(void)
|
|||||||
* Write an XLOG_FPW_CHANGE record. This allows us to keep track of
|
* Write an XLOG_FPW_CHANGE record. This allows us to keep track of
|
||||||
* full_page_writes during archive recovery, if required.
|
* full_page_writes during archive recovery, if required.
|
||||||
*/
|
*/
|
||||||
if (XLogStandbyInfoActive() && !RecoveryInProgress())
|
if (XLogStandbyInfoActive() && !recoveryInProgress)
|
||||||
{
|
{
|
||||||
XLogBeginInsert();
|
XLogBeginInsert();
|
||||||
XLogRegisterData((char *) (&fullPageWrites), sizeof(bool));
|
XLogRegisterData((char *) (&fullPageWrites), sizeof(bool));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user