v2-0005-Fix-XLogNeedsFlush-for-checkpointer.patch
text/x-patch
Filename: v2-0005-Fix-XLogNeedsFlush-for-checkpointer.patch
Type: text/x-patch
Part: 4
Message:
Re: Checkpointer write combining
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v2-0005
Subject: Fix XLogNeedsFlush() for checkpointer
| File | + | − |
|---|---|---|
| src/backend/access/transam/xlog.c | 1 | 1 |
From f11b7be35c56e95efb798242ac0029e6b35d34fb Mon Sep 17 00:00:00 2001
From: Melanie Plageman <melanieplageman@gmail.com>
Date: Tue, 2 Sep 2025 10:01:17 -0400
Subject: [PATCH v2 5/9] Fix XLogNeedsFlush() for checkpointer
XLogNeedsFlush() takes an LSN and compares it to either the flush pointer or the
min recovery point, depending on whether it is in normal operation or recovery.
Even though it is technically recovery, the checkpointer must flush WAL during
an end-of-recovery checkpoint, so in this case, it should compare the provided
LSN to the flush pointer and not the min recovery point.
If it compares the LSN to the min recovery point when the control file's min
recovery point has been updated to an incorrect value, XLogNeedsFlush() can
return an incorrect result of true -- even after just having flushed WAL.
Change this to only compare the LSN to min recovery point -- and, potentially
update the local copy of min recovery point, when xlog inserts are allowed --
which is true for the checkpointer during an end-of-recovery checkpoint, but
false during crash recovery otherwise.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reported-by: Melanie Plageman <melanieplageman@gmail.com>
Discussion: https://postgr.es/m/CAAKRu_a1vZRZRWO3_jv_X13RYoqLRVipGO0237g5PKzPa2YX6g%40mail.gmail.com
---
src/backend/access/transam/xlog.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 7ffb2179151..16ef6d2cd64 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -3115,7 +3115,7 @@ XLogNeedsFlush(XLogRecPtr record)
* instead. So "needs flush" is taken to mean whether minRecoveryPoint
* would need to be updated.
*/
- if (RecoveryInProgress())
+ if (RecoveryInProgress() && !XLogInsertAllowed())
{
/*
* An invalid minRecoveryPoint means that we need to recover all the
--
2.43.0