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
PostgreSQL Database Management System
This directory contains the source code distribution of the PostgreSQL database management system.
PostgreSQL is an advanced object-relational database management system that supports an extended subset of the SQL standard, including transactions, foreign keys, subqueries, triggers, user-defined types and functions. This distribution also contains C language bindings.
Copyright and license information can be found in the file COPYRIGHT.
General documentation about this version of PostgreSQL can be found at https://www.postgresql.org/docs/devel/. In particular, information about building PostgreSQL from the source code can be found at https://www.postgresql.org/docs/devel/installation.html.
The latest version of this software, and related software, may be obtained at https://www.postgresql.org/download/. For more information look at our web site located at https://www.postgresql.org/.