pgsql: Make XLogFlush() and XLogNeedsFlush() decision-making more consi - Mailing list pgsql-committers

From Michael Paquier
Subject pgsql: Make XLogFlush() and XLogNeedsFlush() decision-making more consi
Date
Msg-id E1uzT3P-001RAm-2n@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Make XLogFlush() and XLogNeedsFlush() decision-making more consistent

When deciding which code path to use depending on the state of recovery,
XLogFlush() and XLogNeedsFlush() have been relying on different
criterias:
- XLogFlush() relied on XLogInsertAllowed().
- XLogNeedsFlush() relied on RecoveryInProgress().

Currently, the checkpointer is allowed to insert WAL records while
RecoveryInProgress() returns true for an end-of-recovery checkpoint,
where XLogInsertAllowed() matters.  Using RecoveryInProgress() in
XLogNeedsFlush() did not really matter for its existing callers, as the
checkpointer only called XLogFlush().  However, a feature under
discussion, by Melanie Plageman, needs XLogNeedsFlush() to be able to
work in more contexts, the end-of-recovery checkpoint being one.

This commit changes XLogNeedsFlush() to use XLogInsertAllowed() instead
of RecoveryInProgress(), making the checks in both routines more
consistent.  While on it, an assertion based on XLogNeedsFlush() is
added at the end of XLogFlush(), triggered when flushing a physical
position (not for the normal recovery patch that checks for updates of
the minimum recovery point).  This assertion would fail for example in
the recovery test 015_promotion_pages if XLogNeedsFlush() is changed to
use RecoveryInProgress().  This should be hopefully enough to ensure
that the checks done in both routines remain consistent.

Author: Melanie Plageman <melanieplageman@gmail.com>
Co-authored-by: Dilip Kumar <dilipbalaut@gmail.com>
Reviewed-by: Jeff Davis <pgsql@j-davis.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/CAAKRu_a1vZRZRWO3_jv_X13RYoqLRVipGO0237g5PKzPa2YX6g@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/deb208df4559c922df217354f2c0cb689016a2ed

Modified Files
--------------
src/backend/access/transam/xlog.c | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)


pgsql-committers by date:

Previous
From: Amit Langote
Date:
Subject: pgsql: Fix EPQ crash from missing partition pruning state in EState
Next
From: Amit Kapila
Date:
Subject: pgsql: Improve few errdetail messages introduced in commit 0d48d393d46.