pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feedWAL record CRC calculated incorrectly because of underlying buffer modification
37+ messages / 10 participants
[nested] [flat]
Commits from this thread:
2026-10-29 27caf4ca5a 4232bf96ec 7ac2f74d1b fd1f61e435 Do not take a full-page image for REGBUF_NO_CHANGE buffers
Related threads (commitfest entry WAL record CRC calculated incorrectly because of underlying buffer modification/7532):
Hash index: stop registering pin-only bucket pages in WAL (remove REGBUF_NO_CHANGE)
* WAL record CRC calculated incorrectly because of underlying buffer modification
@ 2024-05-10 13:00 Alexander Lakhin <exclusion@gmail.com>
2024-05-10 15:57 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
0 siblings, 1 reply; 37+ messages in thread
From: Alexander Lakhin @ 2024-05-10 13:00 UTC (permalink / raw)
To: pgsql-hackers
Hello hackers,
I've investigated a recent buildfarm failure:
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=dodo&dt=2024-05-02%2006%3A40%3A36
where the test failed due to a CRC error:
2024-05-02 17:08:18.401 ACST [3406:7] LOG: incorrect resource manager data checksum in record at 0/F14D7A60
(Chipmunk produced similar errors as well:
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=chipmunk&dt=2022-08-25%2019%3A40%3A11
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=chipmunk&dt=2024-03-22%2003%3A20%3A39
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=chipmunk&dt=2023-08-19%2006%3A43%3A20
)
and discovered that XLogRecordAssemble() calculates CRC over a buffer,
that might be modified by another process.
With the attached patch applied, the following test run:
echo "
autovacuum_naptime = 1
autovacuum_vacuum_threshold = 1
wal_consistency_checking = all
" >/tmp/temp.config
for ((i=1;i<=100;i++)); do echo "iteration $i"; TEMP_CONFIG=/tmp/temp.config TESTS="test_setup hash_index" make
check-tests -s || break; done
fails for me on iterations 7, 10, 17:
ok 1 - test_setup 2557 ms
not ok 2 - hash_index 24719 ms
# (test process exited with exit code 2)
postmaster.log contains:
2024-05-10 12:46:44.320 UTC checkpointer[1881151] LOG: checkpoint starting: immediate force wait
2024-05-10 12:46:44.365 UTC checkpointer[1881151] LOG: checkpoint complete: wrote 41 buffers (0.3%); 0 WAL file(s)
added, 0 removed, 26 recycled; write=0.001 s, sync=0.001 s, total=0.046 s; sync files=0, longest=0.000 s, average=0.000
s; distance=439134 kB, estimate=527137 kB; lsn=0/3CE131F0, redo lsn=0/3CE13198
TRAP: failed Assert("memcmp(block1_ptr, block1_copy, block1_len) == 0"), File: "xloginsert.c", Line: 949, PID: 1881271
ExceptionalCondition at assert.c:52:13
XLogRecordAssemble at xloginsert.c:953:1
XLogInsert at xloginsert.c:520:9
hashbucketcleanup at hash.c:844:14
hashbulkdelete at hash.c:558:3
index_bulk_delete at indexam.c:760:1
vac_bulkdel_one_index at vacuum.c:2498:10
lazy_vacuum_one_index at vacuumlazy.c:2443:10
lazy_vacuum_all_indexes at vacuumlazy.c:2026:26
lazy_vacuum at vacuumlazy.c:1944:10
lazy_scan_heap at vacuumlazy.c:1050:3
heap_vacuum_rel at vacuumlazy.c:503:2
vacuum_rel at vacuum.c:2214:2
vacuum at vacuum.c:622:8
autovacuum_do_vac_analyze at autovacuum.c:3102:2
do_autovacuum at autovacuum.c:2425:23
AutoVacWorkerMain at autovacuum.c:1569:3
pgarch_die at pgarch.c:846:1
StartChildProcess at postmaster.c:3929:5
StartAutovacuumWorker at postmaster.c:3997:12
process_pm_pmsignal at postmaster.c:3809:3
ServerLoop at postmaster.c:1667:5
BackgroundWorkerInitializeConnection at postmaster.c:4156:1
main at main.c:184:3
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80)[0x7fc71a8d7e40]
postgres: autovacuum worker regression(_start+0x25)[0x556a8631a5e5]
2024-05-10 12:46:45.038 UTC checkpointer[1881151] LOG: checkpoint starting: immediate force wait
2024-05-10 12:46:45.965 UTC autovacuum worker[1881275] LOG: automatic analyze of table "regression.pg_catalog.pg_attribute"
avg read rate: 0.000 MB/s, avg write rate: 5.409 MB/s
buffer usage: 1094 hits, 0 misses, 27 dirtied
system usage: CPU: user: 0.01 s, system: 0.00 s, elapsed: 0.03 s
2024-05-10 12:46:46.892 UTC postmaster[1881150] LOG: server process (PID 1881271) was terminated by signal 6: Aborted
2024-05-10 12:46:46.892 UTC postmaster[1881150] DETAIL: Failed process was running: autovacuum: VACUUM ANALYZE
public.hash_cleanup_heap
(This can be reproduced with 027_stream_regress, of course, but it would
take more time.)
Best regards,
Alexander
Attachments:
xloginsert-memchk.patch (text/x-patch, 1.0K) download
diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c
index 9047601534..aeb462c137 100644
--- a/src/backend/access/transam/xloginsert.c
+++ b/src/backend/access/transam/xloginsert.c
@@ -902,8 +902,21 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
*/
INIT_CRC32C(rdata_crc);
COMP_CRC32C(rdata_crc, hdr_scratch + SizeOfXLogRecord, hdr_rdt.len - SizeOfXLogRecord);
+
+char block1_copy[BLCKSZ];
+char *block1_ptr = NULL;
+int block1_len = 0;
+
for (rdt = hdr_rdt.next; rdt != NULL; rdt = rdt->next)
+{
+ if (!block1_ptr)
+ {
+ memcpy(block1_copy, rdt->data, rdt->len);
+ block1_ptr = rdt->data;
+ block1_len = rdt->len;
+ }
COMP_CRC32C(rdata_crc, rdt->data, rdt->len);
+}
/*
* Ensure that the XLogRecord is not too large.
@@ -930,6 +943,12 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
rechdr->xl_prev = InvalidXLogRecPtr;
rechdr->xl_crc = rdata_crc;
+if (block1_ptr)
+{
+pg_usleep(100);
+Assert(memcmp(block1_ptr, block1_copy, block1_len) == 0);
+}
+
return &hdr_rdt;
}
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2024-05-10 13:00 WAL record CRC calculated incorrectly because of underlying buffer modification Alexander Lakhin <exclusion@gmail.com>
@ 2024-05-10 15:57 ` Andres Freund <andres@anarazel.de>
2024-05-11 03:26 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Thomas Munro <thomas.munro@gmail.com>
0 siblings, 1 reply; 37+ messages in thread
From: Andres Freund @ 2024-05-10 15:57 UTC (permalink / raw)
To: Alexander Lakhin <exclusion@gmail.com>; +Cc: pgsql-hackers
Hi,
On 2024-05-10 16:00:01 +0300, Alexander Lakhin wrote:
> and discovered that XLogRecordAssemble() calculates CRC over a buffer,
> that might be modified by another process.
If, with "might", you mean that it's legitimate for that buffer to be
modified, I don't think so. The bug is that something is modifying the buffer
despite it being exclusively locked.
I.e. what we likely have here is a bug somewhere in the hash index code.
Greetings,
Andres Freund
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2024-05-10 13:00 WAL record CRC calculated incorrectly because of underlying buffer modification Alexander Lakhin <exclusion@gmail.com>
2024-05-10 15:57 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
@ 2024-05-11 03:26 ` Thomas Munro <thomas.munro@gmail.com>
2024-05-11 04:00 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Alexander Lakhin <exclusion@gmail.com>
0 siblings, 1 reply; 37+ messages in thread
From: Thomas Munro @ 2024-05-11 03:26 UTC (permalink / raw)
To: Andres Freund <andres@anarazel.de>; +Cc: Alexander Lakhin <exclusion@gmail.com>; pgsql-hackers
On Sat, May 11, 2024 at 3:57 AM Andres Freund <andres@anarazel.de> wrote:
> On 2024-05-10 16:00:01 +0300, Alexander Lakhin wrote:
> > and discovered that XLogRecordAssemble() calculates CRC over a buffer,
> > that might be modified by another process.
>
> If, with "might", you mean that it's legitimate for that buffer to be
> modified, I don't think so. The bug is that something is modifying the buffer
> despite it being exclusively locked.
>
> I.e. what we likely have here is a bug somewhere in the hash index code.
I don't have a good grip on the higher level locking protocols of
hash.c, but one microscopic thing jumps out:
/*
* bucket buffer was not changed, but still needs to be
* registered to ensure that we can acquire a cleanup lock on
* it during replay.
*/
if (!xlrec.is_primary_bucket_page)
{
uint8 flags = REGBUF_STANDARD |
REGBUF_NO_IMAGE | REGBUF_NO_CHANGE;
XLogRegisterBuffer(0, bucket_buf, flags);
}
That registers a buffer that is pinned but not content-locked, and we
tell xloginsert.c not to copy its image into the WAL, but it does it
anyway because:
/*
* If needs_backup is true or WAL checking is enabled for current
* resource manager, log a full-page write for the current block.
*/
include_image = needs_backup || (info & XLR_CHECK_CONSISTENCY) != 0;
So I guess it copies the image on dodo, which has:
'PG_TEST_EXTRA' => 'ssl ldap
kerberos wal_consistency_checking libpq_encryption xid_wraparound'
Perhaps a no-image, no-change registered buffer should not be
including an image, even for XLR_CHECK_CONSISTENCY? It's actually
useless for consistency checking too I guess, this issue aside,
because it doesn't change anything so there is nothing to check.
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2024-05-10 13:00 WAL record CRC calculated incorrectly because of underlying buffer modification Alexander Lakhin <exclusion@gmail.com>
2024-05-10 15:57 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2024-05-11 03:26 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Thomas Munro <thomas.munro@gmail.com>
@ 2024-05-11 04:00 ` Alexander Lakhin <exclusion@gmail.com>
2024-05-11 04:25 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Thomas Munro <thomas.munro@gmail.com>
0 siblings, 1 reply; 37+ messages in thread
From: Alexander Lakhin @ 2024-05-11 04:00 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@gmail.com>; Andres Freund <andres@anarazel.de>; +Cc: pgsql-hackers
Hello Thomas and Andres,
Thank you for looking at this!
11.05.2024 06:26, Thomas Munro wrote:
> On Sat, May 11, 2024 at 3:57 AM Andres Freund <andres@anarazel.de> wrote:
>> On 2024-05-10 16:00:01 +0300, Alexander Lakhin wrote:
>>> and discovered that XLogRecordAssemble() calculates CRC over a buffer,
>>> that might be modified by another process.
>> If, with "might", you mean that it's legitimate for that buffer to be
>> modified, I don't think so. The bug is that something is modifying the buffer
>> despite it being exclusively locked.
>>
>> I.e. what we likely have here is a bug somewhere in the hash index code.
> I don't have a good grip on the higher level locking protocols of
> hash.c, but one microscopic thing jumps out:
>
> /*
> * bucket buffer was not changed, but still needs to be
> * registered to ensure that we can acquire a cleanup lock on
> * it during replay.
> */
> if (!xlrec.is_primary_bucket_page)
> {
> uint8 flags = REGBUF_STANDARD |
> REGBUF_NO_IMAGE | REGBUF_NO_CHANGE;
>
> XLogRegisterBuffer(0, bucket_buf, flags);
> }
>
> That registers a buffer that is pinned but not content-locked, and we
> tell xloginsert.c not to copy its image into the WAL, but it does it
> anyway because:
>
> /*
> * If needs_backup is true or WAL checking is enabled for current
> * resource manager, log a full-page write for the current block.
> */
> include_image = needs_backup || (info & XLR_CHECK_CONSISTENCY) != 0;
>
> So I guess it copies the image on dodo, which has:
>
> 'PG_TEST_EXTRA' => 'ssl ldap
> kerberos wal_consistency_checking libpq_encryption xid_wraparound'
>
> Perhaps a no-image, no-change registered buffer should not be
> including an image, even for XLR_CHECK_CONSISTENCY? It's actually
> useless for consistency checking too I guess, this issue aside,
> because it doesn't change anything so there is nothing to check.
Yes, I think something wrong is here. I've reduced the reproducer to:
cat << 'EOF' | psql
CREATE TABLE hash_cleanup_heap(keycol INT);
CREATE INDEX hash_cleanup_index on hash_cleanup_heap USING HASH (keycol);
BEGIN;
INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 500) as i;
ROLLBACK;
EOF
cat << 'EOF' | psql &
INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 500) as i;
DROP TABLE hash_cleanup_heap;
EOF
cat << 'EOF' | psql &
SELECT pg_sleep(random() / 20);
VACUUM hash_cleanup_heap;
EOF
wait
grep 'TRAP:' server.log
("wal_consistency_checking = all" and the xloginsert patch are still required)
and with additional logging I see:
2024-05-11 03:45:23.424 UTC|law|regression|663ee9d3.1f96dd|LOG: !!!hashbucketcleanup| scan page buf: 1832
2024-05-11 03:45:23.424 UTC|law|regression|663ee9d3.1f96dd|CONTEXT: while vacuuming index "hash_cleanup_index" of
relation "public.hash_cleanup_heap"
2024-05-11 03:45:23.424 UTC|law|regression|663ee9d3.1f96dd|STATEMENT: VACUUM hash_cleanup_heap;
2024-05-11 03:45:23.424 UTC|law|regression|663ee9d3.1f96de|LOG: !!!_hash_doinsert| _hash_getbucketbuf_from_hashkey: 1822
2024-05-11 03:45:23.424 UTC|law|regression|663ee9d3.1f96de|STATEMENT: INSERT INTO hash_cleanup_heap SELECT 1 FROM
generate_series(1, 500) as i;
2024-05-11 03:45:23.424 UTC|law|regression|663ee9d3.1f96dd|LOG: !!!hashbucketcleanup| xlrec.is_primary_bucket_page: 0,
buf: 1832, bucket_buf: 1822
2024-05-11 03:45:23.424 UTC|law|regression|663ee9d3.1f96dd|CONTEXT: while vacuuming index "hash_cleanup_index" of
relation "public.hash_cleanup_heap"
2024-05-11 03:45:23.424 UTC|law|regression|663ee9d3.1f96dd|STATEMENT: VACUUM hash_cleanup_heap;
2024-05-11 03:45:23.424 UTC|law|regression|663ee9d3.1f96de|LOG: !!!_hash_doinsert| _hash_relbuf(rel, 1822)
2024-05-11 03:45:23.424 UTC|law|regression|663ee9d3.1f96de|STATEMENT: INSERT INTO hash_cleanup_heap SELECT 1 FROM
generate_series(1, 500) as i;
TRAP: failed Assert("memcmp(block1_ptr, block1_copy, block1_len) == 0"), File: "xloginsert.c", Line: 949, PID: 2070237
Best regards,
Alexander
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2024-05-10 13:00 WAL record CRC calculated incorrectly because of underlying buffer modification Alexander Lakhin <exclusion@gmail.com>
2024-05-10 15:57 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2024-05-11 03:26 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Thomas Munro <thomas.munro@gmail.com>
2024-05-11 04:00 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Alexander Lakhin <exclusion@gmail.com>
@ 2024-05-11 04:25 ` Thomas Munro <thomas.munro@gmail.com>
2024-05-11 05:00 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Alexander Lakhin <exclusion@gmail.com>
0 siblings, 1 reply; 37+ messages in thread
From: Thomas Munro @ 2024-05-11 04:25 UTC (permalink / raw)
To: Alexander Lakhin <exclusion@gmail.com>; +Cc: Andres Freund <andres@anarazel.de>; pgsql-hackers; Michael Paquier <michael@paquier.xyz>; Amit Kapila <amit.kapila16@gmail.com>
On Sat, May 11, 2024 at 4:00 PM Alexander Lakhin <exclusion@gmail.com> wrote:
> 11.05.2024 06:26, Thomas Munro wrote:
> > Perhaps a no-image, no-change registered buffer should not be
> > including an image, even for XLR_CHECK_CONSISTENCY? It's actually
> > useless for consistency checking too I guess, this issue aside,
> > because it doesn't change anything so there is nothing to check.
>
> Yes, I think something wrong is here. I've reduced the reproducer to:
Does it reproduce if you do this?
- include_image = needs_backup || (info &
XLR_CHECK_CONSISTENCY) != 0;
+ include_image = needs_backup ||
+ ((info & XLR_CHECK_CONSISTENCY) != 0 &&
+ (regbuf->flags & REGBUF_NO_CHANGE) == 0);
Unfortunately the back branches don't have that new flag from 00d7fb5e
so, even if this is the right direction (not sure, I don't understand
this clean registered buffer trick) then ... but wait, why are there
are no failures like this in the back branches (yet at least)? Does
your reproducer work for 16? I wonder if something relevant changed
recently, like f56a9def. CC'ing Michael and Amit K for info.
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2024-05-10 13:00 WAL record CRC calculated incorrectly because of underlying buffer modification Alexander Lakhin <exclusion@gmail.com>
2024-05-10 15:57 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2024-05-11 03:26 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Thomas Munro <thomas.munro@gmail.com>
2024-05-11 04:00 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Alexander Lakhin <exclusion@gmail.com>
2024-05-11 04:25 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Thomas Munro <thomas.munro@gmail.com>
@ 2024-05-11 05:00 ` Alexander Lakhin <exclusion@gmail.com>
2024-05-12 23:15 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Thomas Munro <thomas.munro@gmail.com>
0 siblings, 1 reply; 37+ messages in thread
From: Alexander Lakhin @ 2024-05-11 05:00 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@gmail.com>; +Cc: Andres Freund <andres@anarazel.de>; pgsql-hackers; Michael Paquier <michael@paquier.xyz>; Amit Kapila <amit.kapila16@gmail.com>
11.05.2024 07:25, Thomas Munro wrote:
> On Sat, May 11, 2024 at 4:00 PM Alexander Lakhin <exclusion@gmail.com> wrote:
>> 11.05.2024 06:26, Thomas Munro wrote:
>>> Perhaps a no-image, no-change registered buffer should not be
>>> including an image, even for XLR_CHECK_CONSISTENCY? It's actually
>>> useless for consistency checking too I guess, this issue aside,
>>> because it doesn't change anything so there is nothing to check.
>> Yes, I think something wrong is here. I've reduced the reproducer to:
> Does it reproduce if you do this?
>
> - include_image = needs_backup || (info &
> XLR_CHECK_CONSISTENCY) != 0;
> + include_image = needs_backup ||
> + ((info & XLR_CHECK_CONSISTENCY) != 0 &&
> + (regbuf->flags & REGBUF_NO_CHANGE) == 0);
No, it doesn't (at least with the latter, more targeted reproducer).
> Unfortunately the back branches don't have that new flag from 00d7fb5e
> so, even if this is the right direction (not sure, I don't understand
> this clean registered buffer trick) then ... but wait, why are there
> are no failures like this in the back branches (yet at least)? Does
> your reproducer work for 16? I wonder if something relevant changed
> recently, like f56a9def. CC'ing Michael and Amit K for info.
Maybe it's hard to hit (autovacuum needs to process the index page in a
narrow time frame), but locally I could reproduce the issue even on
ac27c74de(~1 too) from 2018-09-06 (I tried several last commits touching
hash indexes, didn't dig deeper).
Best regards,
Alexander
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2024-05-10 13:00 WAL record CRC calculated incorrectly because of underlying buffer modification Alexander Lakhin <exclusion@gmail.com>
2024-05-10 15:57 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2024-05-11 03:26 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Thomas Munro <thomas.munro@gmail.com>
2024-05-11 04:00 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Alexander Lakhin <exclusion@gmail.com>
2024-05-11 04:25 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Thomas Munro <thomas.munro@gmail.com>
2024-05-11 05:00 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Alexander Lakhin <exclusion@gmail.com>
@ 2024-05-12 23:15 ` Thomas Munro <thomas.munro@gmail.com>
2024-05-16 22:54 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Jeff Davis <pgsql@j-davis.com>
0 siblings, 1 reply; 37+ messages in thread
From: Thomas Munro @ 2024-05-12 23:15 UTC (permalink / raw)
To: Alexander Lakhin <exclusion@gmail.com>; +Cc: Andres Freund <andres@anarazel.de>; pgsql-hackers; Michael Paquier <michael@paquier.xyz>; Amit Kapila <amit.kapila16@gmail.com>; Heikki Linnakangas <hlinnaka@iki.fi>; Jeff Davis <pgsql@j-davis.com>
On Sat, May 11, 2024 at 5:00 PM Alexander Lakhin <exclusion@gmail.com> wrote:
> 11.05.2024 07:25, Thomas Munro wrote:
> > On Sat, May 11, 2024 at 4:00 PM Alexander Lakhin <exclusion@gmail.com> wrote:
> >> 11.05.2024 06:26, Thomas Munro wrote:
> >>> Perhaps a no-image, no-change registered buffer should not be
> >>> including an image, even for XLR_CHECK_CONSISTENCY? It's actually
> >>> useless for consistency checking too I guess, this issue aside,
> >>> because it doesn't change anything so there is nothing to check.
> >> Yes, I think something wrong is here. I've reduced the reproducer to:
> > Does it reproduce if you do this?
> >
> > - include_image = needs_backup || (info &
> > XLR_CHECK_CONSISTENCY) != 0;
> > + include_image = needs_backup ||
> > + ((info & XLR_CHECK_CONSISTENCY) != 0 &&
> > + (regbuf->flags & REGBUF_NO_CHANGE) == 0);
>
> No, it doesn't (at least with the latter, more targeted reproducer).
OK so that seems like a candidate fix, but ...
> > Unfortunately the back branches don't have that new flag from 00d7fb5e
> > so, even if this is the right direction (not sure, I don't understand
> > this clean registered buffer trick) then ... but wait, why are there
> > are no failures like this in the back branches (yet at least)? Does
> > your reproducer work for 16? I wonder if something relevant changed
> > recently, like f56a9def. CC'ing Michael and Amit K for info.
>
> Maybe it's hard to hit (autovacuum needs to process the index page in a
> narrow time frame), but locally I could reproduce the issue even on
> ac27c74de(~1 too) from 2018-09-06 (I tried several last commits touching
> hash indexes, didn't dig deeper).
... we'd need to figure out how to fix this in the back-branches too.
One idea would be to back-patch REGBUF_NO_CHANGE, and another might be
to deduce that case from other variables. Let me CC a couple more
people from this thread, which most recently hacked on this stuff, to
see if they have insights:
https://www.postgresql.org/message-id/flat/d2c31606e6bb9b83a02ed4835d65191b38d4ba12.camel%40j-davis....
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2024-05-10 13:00 WAL record CRC calculated incorrectly because of underlying buffer modification Alexander Lakhin <exclusion@gmail.com>
2024-05-10 15:57 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2024-05-11 03:26 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Thomas Munro <thomas.munro@gmail.com>
2024-05-11 04:00 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Alexander Lakhin <exclusion@gmail.com>
2024-05-11 04:25 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Thomas Munro <thomas.munro@gmail.com>
2024-05-11 05:00 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Alexander Lakhin <exclusion@gmail.com>
2024-05-12 23:15 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Thomas Munro <thomas.munro@gmail.com>
@ 2024-05-16 22:54 ` Jeff Davis <pgsql@j-davis.com>
2024-05-17 01:12 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
0 siblings, 1 reply; 37+ messages in thread
From: Jeff Davis @ 2024-05-16 22:54 UTC (permalink / raw)
To: Thomas Munro <thomas.munro@gmail.com>; Alexander Lakhin <exclusion@gmail.com>; +Cc: Andres Freund <andres@anarazel.de>; pgsql-hackers; Michael Paquier <michael@paquier.xyz>; Amit Kapila <amit.kapila16@gmail.com>; Heikki Linnakangas <hlinnaka@iki.fi>
On Mon, 2024-05-13 at 11:15 +1200, Thomas Munro wrote:
> > > > > Perhaps a no-image, no-change registered buffer should not be
> > > > > including an image, even for XLR_CHECK_CONSISTENCY? It's
> > > > > actually
> > > > > useless for consistency checking too I guess, this issue
> > > > > aside,
> > > > > because it doesn't change anything so there is nothing to
> > > > > check.
I'm not convinced by that reasoning. Can't it check that nothing has
changed?
> > >
> > > Does it reproduce if you do this?
> > >
> > > - include_image = needs_backup || (info &
> > > XLR_CHECK_CONSISTENCY) != 0;
> > > + include_image = needs_backup ||
> > > + ((info & XLR_CHECK_CONSISTENCY) != 0 &&
> > > + (regbuf->flags & REGBUF_NO_CHANGE) ==
> > > 0);
> >
> > No, it doesn't (at least with the latter, more targeted
> > reproducer).
>
> OK so that seems like a candidate fix, but ...
...
> ... we'd need to figure out how to fix this in the back-branches too.
> One idea would be to back-patch REGBUF_NO_CHANGE, and another might
> be
> to deduce that case from other variables. Let me CC a couple more
> people from this thread, which most recently hacked on this stuff, to
> see if they have insights:
Starting from the beginning, XLogRecordAssemble() calculates the CRC of
the record (technically just the non-header portions, but that's not
important here), including any backup blocks. Later,
CopyXLogRecordToWAL() copies that data into the actual xlog buffers. If
the data changes between those two steps, the CRC will be bad.
For most callers, the contents are exclusive-locked, so there's no
problem. For checksums, the data is copied out of shared memory into a
stack variable first, so no concurrent activity can change it. For hash
indexes, it tries to protect itself by passing REGBUF_NO_IMAGE.
There are two problems:
1. That implies another invariant that we aren't checking for: that
REGBUF_NO_CHANGE must be accompanied by REGBUF_NO_IMAGE. That doesn't
seem to be true for all callers, see XLogRegisterBuffer(1, wbuf,
wbuf_flags) in _hash_freeovflpage().
2. As you point out, REGBUF_NO_IMAGE still allows an image to be taken
if XLR_CHECK_CONSISTENCY is set, so we need to figure out what to do
there.
Can we take a step back and think harder about what hash indexes are
doing and if there's a better way? Maybe hash indexes need to take a
copy of the page, like in XLogSaveBufferForHint()?
I'd prefer that we find a way to get rid of REGBUF_NO_CHANGE and make
all callers follow the rules than to find new special cases that depend
on REGBUF_NO_CHANGE. See these messages here:
https://www.postgresql.org/message-id/b1f2d0f230d60fa8df33bb0b2af3236fde9d750d.camel%40j-davis.com
https://www.postgresql.org/message-id/CA%2BTgmoY%2BdagCyrMKau7UQeQU6w4LuVEu%2ByjsmJBoXKAo6XbUUA%40ma...
In other words, we added REGBUF_NO_CHANGE for the call sites (only hash
indexes) that don't follow the rules and where it wasn't easy to make
them follow the rules. Now that we know of a concrete problem with the
design, there's more upside to fixing it properly.
Regards,
Jeff Davis
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2024-05-10 13:00 WAL record CRC calculated incorrectly because of underlying buffer modification Alexander Lakhin <exclusion@gmail.com>
2024-05-10 15:57 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2024-05-11 03:26 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Thomas Munro <thomas.munro@gmail.com>
2024-05-11 04:00 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Alexander Lakhin <exclusion@gmail.com>
2024-05-11 04:25 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Thomas Munro <thomas.munro@gmail.com>
2024-05-11 05:00 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Alexander Lakhin <exclusion@gmail.com>
2024-05-12 23:15 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Thomas Munro <thomas.munro@gmail.com>
2024-05-16 22:54 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Jeff Davis <pgsql@j-davis.com>
@ 2024-05-17 01:12 ` Michael Paquier <michael@paquier.xyz>
2024-05-17 14:56 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Jeff Davis <pgsql@j-davis.com>
0 siblings, 1 reply; 37+ messages in thread
From: Michael Paquier @ 2024-05-17 01:12 UTC (permalink / raw)
To: Jeff Davis <pgsql@j-davis.com>; +Cc: Thomas Munro <thomas.munro@gmail.com>; Alexander Lakhin <exclusion@gmail.com>; Andres Freund <andres@anarazel.de>; pgsql-hackers; Amit Kapila <amit.kapila16@gmail.com>; Heikki Linnakangas <hlinnaka@iki.fi>
On Thu, May 16, 2024 at 03:54:52PM -0700, Jeff Davis wrote:
> On Mon, 2024-05-13 at 11:15 +1200, Thomas Munro wrote:
>>>>>> Perhaps a no-image, no-change registered buffer should not be
>>>>>> including an image, even for XLR_CHECK_CONSISTENCY? It's
>>>>>> actually
>>>>>> useless for consistency checking too I guess, this issue
>>>>>> aside,
>>>>>> because it doesn't change anything so there is nothing to
>>>>>> check.
>
> I'm not convinced by that reasoning. Can't it check that nothing has
> changed?
That's something I've done four weeks ago in the hash replay code
path, and having the image with XLR_CHECK_CONSISTENCY even if
REGBUF_NO_CHANGE was necessary because replay was setting up a LSN on
a REGBUF_NO_CHANGE page it should not have touched.
> I'd prefer that we find a way to get rid of REGBUF_NO_CHANGE and make
> all callers follow the rules than to find new special cases that depend
> on REGBUF_NO_CHANGE. See these messages here:
>
> https://www.postgresql.org/message-id/b1f2d0f230d60fa8df33bb0b2af3236fde9d750d.camel%40j-davis.com
>
> https://www.postgresql.org/message-id/CA%2BTgmoY%2BdagCyrMKau7UQeQU6w4LuVEu%2ByjsmJBoXKAo6XbUUA%40ma...
>
> In other words, we added REGBUF_NO_CHANGE for the call sites (only hash
> indexes) that don't follow the rules and where it wasn't easy to make
> them follow the rules. Now that we know of a concrete problem with the
> design, there's more upside to fixing it properly.
Yeah, agreed that getting rid of REGBUF_NO_CHANGE would be nice in the
final picture. It still strikes me as a weird concept that WAL replay
for hash indexes logs full pages just to be able to lock them at
replay based on what's in the records. :/
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2024-05-10 13:00 WAL record CRC calculated incorrectly because of underlying buffer modification Alexander Lakhin <exclusion@gmail.com>
2024-05-10 15:57 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2024-05-11 03:26 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Thomas Munro <thomas.munro@gmail.com>
2024-05-11 04:00 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Alexander Lakhin <exclusion@gmail.com>
2024-05-11 04:25 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Thomas Munro <thomas.munro@gmail.com>
2024-05-11 05:00 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Alexander Lakhin <exclusion@gmail.com>
2024-05-12 23:15 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Thomas Munro <thomas.munro@gmail.com>
2024-05-16 22:54 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Jeff Davis <pgsql@j-davis.com>
2024-05-17 01:12 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
@ 2024-05-17 14:56 ` Jeff Davis <pgsql@j-davis.com>
2024-05-17 15:38 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Robert Haas <robertmhaas@gmail.com>
0 siblings, 1 reply; 37+ messages in thread
From: Jeff Davis @ 2024-05-17 14:56 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; +Cc: Thomas Munro <thomas.munro@gmail.com>; Alexander Lakhin <exclusion@gmail.com>; Andres Freund <andres@anarazel.de>; pgsql-hackers; Amit Kapila <amit.kapila16@gmail.com>; Heikki Linnakangas <hlinnaka@iki.fi>
On Fri, 2024-05-17 at 10:12 +0900, Michael Paquier wrote:
> That's something I've done four weeks ago in the hash replay code
> path, and having the image with XLR_CHECK_CONSISTENCY even if
> REGBUF_NO_CHANGE was necessary because replay was setting up a LSN on
> a REGBUF_NO_CHANGE page it should not have touched.
Then the candidate fix to selectively break XLR_CHECK_CONSISTENCY is
not acceptable.
>
> Yeah, agreed that getting rid of REGBUF_NO_CHANGE would be nice in
> the
> final picture. It still strikes me as a weird concept that WAL
> replay
> for hash indexes logs full pages just to be able to lock them at
> replay based on what's in the records. :/
I'm still not entirely clear on why hash indexes can't just follow the
rules and exclusive lock the buffer and dirty it. Presumably
performance would suffer, but I asked that question previously and
didn't get an answer:
https://www.postgresql.org/message-id/CA%2BTgmoY%2BdagCyrMKau7UQeQU6w4LuVEu%2ByjsmJBoXKAo6XbUUA%40ma...
And if that does affect performance, what about following the same
protocol as XLogSaveBufferForHint()?
Regards,
Jeff Davis
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2024-05-10 13:00 WAL record CRC calculated incorrectly because of underlying buffer modification Alexander Lakhin <exclusion@gmail.com>
2024-05-10 15:57 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2024-05-11 03:26 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Thomas Munro <thomas.munro@gmail.com>
2024-05-11 04:00 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Alexander Lakhin <exclusion@gmail.com>
2024-05-11 04:25 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Thomas Munro <thomas.munro@gmail.com>
2024-05-11 05:00 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Alexander Lakhin <exclusion@gmail.com>
2024-05-12 23:15 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Thomas Munro <thomas.munro@gmail.com>
2024-05-16 22:54 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Jeff Davis <pgsql@j-davis.com>
2024-05-17 01:12 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
2024-05-17 14:56 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Jeff Davis <pgsql@j-davis.com>
@ 2024-05-17 15:38 ` Robert Haas <robertmhaas@gmail.com>
0 siblings, 0 replies; 37+ messages in thread
From: Robert Haas @ 2024-05-17 15:38 UTC (permalink / raw)
To: Jeff Davis <pgsql@j-davis.com>; +Cc: Michael Paquier <michael@paquier.xyz>; Thomas Munro <thomas.munro@gmail.com>; Alexander Lakhin <exclusion@gmail.com>; Andres Freund <andres@anarazel.de>; pgsql-hackers; Amit Kapila <amit.kapila16@gmail.com>; Heikki Linnakangas <hlinnaka@iki.fi>
On Fri, May 17, 2024 at 10:56 AM Jeff Davis <pgsql@j-davis.com> wrote:
> I'm still not entirely clear on why hash indexes can't just follow the
> rules and exclusive lock the buffer and dirty it. Presumably
> performance would suffer, but I asked that question previously and
> didn't get an answer:
>
> https://www.postgresql.org/message-id/CA%2BTgmoY%2BdagCyrMKau7UQeQU6w4LuVEu%2ByjsmJBoXKAo6XbUUA%40ma...
In my defense, the last time I worked on hash indexes was 7 years ago.
If this question had come up within a year or two of that work, I
probably would have both (a) had a much clearer idea of what the
answer was and (b) felt obliged to drop everything and go research it
if I didn't. But at this point, I feel like it's fair for me to tell
you what I know and leave it to you to do further research if you feel
like that's warranted. I know that we're each responsible for what we
commit, but I don't really think that should extend to having to
prioritize answering a hypothetical question ("what would happen if X
thing worked like Y instead of the way it does?") about an area I
haven't touched in long enough for every release that doesn't contain
those commits to be out of support. If you feel otherwise, let's have
that argument, but I have a feeling that it may be more that you're
hoping I have some kind of oracular powers which, in reality, I lack.
--
Robert Haas
EDB: http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
@ 2026-10-23 10:48 Greg Burd <greg@burd.me>
2026-10-26 03:17 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
0 siblings, 1 reply; 37+ messages in thread
From: Greg Burd @ 2026-10-23 10:48 UTC (permalink / raw)
To: pgsql-hackers; +Cc: pgsql@j-davis.com; michael@paquier.xyz; thomas.munro@gmail.com; exclusion@gmail.com; andres@anarazel.de; amit.kapila16@gmail.com; hlinnaka@iki.fi
On Fri, 17 May 2024 07:56:23 -0700, Jeff Davis <pgsql@j-davis.com> wrote:
> On Fri, 2024-05-17 at 10:12 +0900, Michael Paquier wrote:
> > That's something I've done four weeks ago in the hash replay code
> > path, and having the image with XLR_CHECK_CONSISTENCY even if
> > REGBUF_NO_CHANGE was necessary because replay was setting up a LSN on
> > a REGBUF_NO_CHANGE page it should not have touched.
>
> Then the candidate fix to selectively break XLR_CHECK_CONSISTENCY is
> not acceptable.
>
> >
> > Yeah, agreed that getting rid of REGBUF_NO_CHANGE would be nice in
> > the
> > final picture. It still strikes me as a weird concept that WAL
> > replay
> > for hash indexes logs full pages just to be able to lock them at
> > replay based on what's in the records. :/
>
> I'm still not entirely clear on why hash indexes can't just follow the
> rules and exclusive lock the buffer and dirty it. Presumably
> performance would suffer, but I asked that question previously and
> didn't get an answer:
>
> https://www.postgresql.org/message-id/CA%2BTgmoY%2BdagCyrMKau7UQeQU6w4LuVEu%2ByjsmJBoXKAo6XbUUA%40ma...
>
> And if that does affect performance, what about following the same
> protocol as XLogSaveBufferForHint()?
>
> Regards,
> Jeff Davis
Hi,
Reviving this thread because I hit the same CRC failure on current
master while testing something else.
Recap of the bug:
hashbucketcleanup(), _hash_freeovflpage() and _hash_squeezebucket()
register the primary bucket page with REGBUF_STANDARD | REGBUF_NO_IMAGE
| REGBUF_NO_CHANGE, holding only a pin on it, purely to force a cleanup
lock during replay. With wal_consistency_checking covering the hash RM,
XLogRecordAssemble() takes a full-page image of that block anyway:
include_image = needs_backup || (info & XLR_CHECK_CONSISTENCY) != 0;
The CRC is then computed over a page another backend is free to modify
(it holds only a pin), and before CopyXLogRecordToWAL() runs the page
changes, so the record lands with a bad CRC. On a standby that is a
fatal "incorrect resource manager data checksum in record".
AFAICT, 2 things kept this open last time:
1. Thomas's narrow fix (skip the image for REGBUF_NO_CHANGE) was ruled
out because Michael's f56a9def seemed to rely on an image being present
for a REGBUF_NO_CHANGE page. Looking again, f56a9def is on the squeeze
*redo* path: it stops replay from setting an LSN on the write buffer
(block 1) when that buffer turns out not to be modified. That redo code
reads only the per-buffer data registered with XLogRegisterBufData() and
the xl_hash_squeeze_page fields, never a full-page image, so suppressing
the image does not affect it. The block that triggers the CRC failure
is a different one: the primary bucket page registered as block 0 only
to take a cleanup lock, which is never image-applied at replay.
Suppressing its image is safe.
2. Jeff asked why hash can't just follow the rules and exclusive-lock +
dirty the buffer. That is the better long-term answer, but it is a
non-trivial rework of the hash cleanup/squeeze locking and does not
back-patch cleanly. The attached fix is the minimal, back-patchable
change and does not foreclose the rework.
Proposed fix:
Never take a full-page image for a REGBUF_NO_CHANGE buffer, even under
XLR_CHECK_CONSISTENCY.
The reasoning is the same one Thomas gave: there is nothing to
consistency-check on a block the record does not change, and the page is
not safe to read while assembling the record.
verifyBackupPageConsistency() is taught to skip a registered block that
carries no image, rather than asserting one is present (that assertion
is what fires first on an assert build with the fix in place).
This keeps REGBUF_NO_CHANGE as the single, documented marker for "pinned
but not content-locked, not modified here" and makes its
consistency-check behaviour match its contract.
Testing:
I reproduced the failure with a primary plus a streaming standby,
wal_consistency_checking='hash', and eight sessions doing:
INSERT INTO h SELECT 1 FROM generate_series(1,400);
DELETE FROM h WHERE ctid IN (SELECT ctid FROM h LIMIT 150);
against a single-bucket hash index, with aggressive autovacuum. On
unpatched master the standby dies with the CRC error within a few
seconds, every run. With the patch, runs replayed clean and the standby
caught up each time.
This still reproduces on all supported back branches (Alexander saw it
as far back as 2018); REGBUF_NO_CHANGE exists only since 00d7fb5e (v17),
so the back-patch needs the equivalent condition expressed without the
flag. I can prepare those once the master approach has agreement.
best.
-greg
Attachments:
walcrc.patch (text/plain, 6.0K) download
From 09a645463af50abdfb3b9ea20decee42ff88d4b1 Mon Sep 17 00:00:00 2001
From: Greg Burd <greg@burd.me>
Date: Thu, 22 Oct 2026 14:43:17 -0400
Subject: [PATCH] Don't take a full-page image for REGBUF_NO_CHANGE buffers
A buffer registered with REGBUF_NO_CHANGE is not modified by the record
and may be held with only a pin (no content lock). The hash index code
registers the primary bucket page this way in hashbucketcleanup(),
_hash_freeovflpage() and _hash_squeezebucket(), solely to force a cleanup
lock on that block during replay.
When wal_consistency_checking includes the hash RM, XLogRecordAssemble()
included a full-page image for such a block anyway, because
XLR_CHECK_CONSISTENCY forces an image regardless of REGBUF_NO_IMAGE. The
record CRC is then computed over the image while a concurrent backend,
which legitimately holds nothing stronger than a pin on that page, is
free to modify it before the record is copied into the WAL buffers. The
result is an intermittent "incorrect resource manager data checksum in
record" failure on a standby (or under a crash-recovery consistency
check), reproducible on the buildfarm with wal_consistency_checking and
concurrent inserts plus autovacuum on a hash index.
Fix by never taking an image for a REGBUF_NO_CHANGE buffer, even under
XLR_CHECK_CONSISTENCY. There is nothing to consistency-check on a block
the record does not change, and the page is not safe to read while
assembling the record. verifyBackupPageConsistency() is taught to skip a
registered block that carries no image rather than asserting one is
present.
Reported-by: Alexander Lakhin
Diagnosed-by: Thomas Munro
Discussion: https://postgr.es/m/055bb33c-bccc-bc1d-c2f8-8598534448ac@gmail.com
---
src/backend/access/transam/README | 9 +++++++++
src/backend/access/transam/xloginsert.c | 15 ++++++++++++++-
src/backend/access/transam/xlogrecovery.c | 8 +++++++-
src/include/access/xloginsert.h | 7 ++++++-
4 files changed, 36 insertions(+), 3 deletions(-)
diff --git a/src/backend/access/transam/README b/src/backend/access/transam/README
index 231106270fd..138c4c0ada6 100644
--- a/src/backend/access/transam/README
+++ b/src/backend/access/transam/README
@@ -586,6 +586,15 @@ void XLogRegisterBuffer(uint8 block_id, Buffer buf, uint8 flags);
XLogRegisterBufData() is included in the WAL record even if a full-page
image is taken.
+ The REGBUF_NO_CHANGE flag indicates that the buffer is registered without
+ being modified by this record, and possibly without an exclusive content
+ lock (for example, to force a cleanup lock on the block during replay).
+ Such a buffer never has a full-page image taken, not even when WAL
+ consistency checking is enabled: its contents may change concurrently
+ while the record is assembled, which would compute the record CRC over
+ data a concurrent backend can still modify, and there is nothing to
+ consistency-check on a block the record does not change.
+
void XLogRegisterData(const void *data, int len);
XLogRegisterData is used to include arbitrary data in the WAL record. If
diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c
index 59b0dfe436d..c3c95f89276 100644
--- a/src/backend/access/transam/xloginsert.c
+++ b/src/backend/access/transam/xloginsert.c
@@ -721,8 +721,21 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
/*
* If needs_backup is true or WAL checking is enabled for current
* resource manager, log a full-page write for the current block.
+ *
+ * However, a buffer registered with REGBUF_NO_CHANGE is not modified
+ * by this record and may be held with only a pin (no content lock),
+ * so its contents could change under us while we assemble the record.
+ * Including such a page would compute the record CRC over data that a
+ * concurrent backend can modify before the record is copied into the
+ * WAL buffers, producing a spurious "incorrect resource manager data
+ * checksum" failure. These blocks are registered only to force a
+ * cleanup lock during replay, so there is nothing to consistency-check
+ * anyway; never take an image for them.
*/
- include_image = needs_backup || (info & XLR_CHECK_CONSISTENCY) != 0;
+ if (regbuf->flags & REGBUF_NO_CHANGE)
+ include_image = needs_backup;
+ else
+ include_image = needs_backup || (info & XLR_CHECK_CONSISTENCY) != 0;
if (include_image)
{
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 20be788da78..52cb5cdc0a1 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -2479,7 +2479,13 @@ verifyBackupPageConsistency(XLogReaderState *record)
continue;
}
- Assert(XLogRecHasBlockImage(record, block_id));
+ /*
+ * A block registered with REGBUF_NO_CHANGE is not modified by this
+ * record and carries no full-page image (see XLogRecordAssemble), so
+ * there is nothing to consistency-check for it. Skip it.
+ */
+ if (!XLogRecHasBlockImage(record, block_id))
+ continue;
if (XLogRecBlockImageApply(record, block_id))
{
diff --git a/src/include/access/xloginsert.h b/src/include/access/xloginsert.h
index 91dfbd5627f..6ae2692d5b9 100644
--- a/src/include/access/xloginsert.h
+++ b/src/include/access/xloginsert.h
@@ -38,7 +38,12 @@
* will be skipped) */
#define REGBUF_KEEP_DATA 0x10 /* include data even if a full-page image
* is taken */
-#define REGBUF_NO_CHANGE 0x20 /* intentionally register clean buffer */
+#define REGBUF_NO_CHANGE 0x20 /* intentionally register clean buffer;
+ * suppresses the full-page image that
+ * XLR_CHECK_CONSISTENCY would otherwise
+ * take, since the page is not changed by
+ * this record and may not be
+ * content-locked */
/* prototypes for public functions in xloginsert.c: */
extern void XLogBeginInsert(void);
--
2.54.0
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2026-10-23 10:48 Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
@ 2026-10-26 03:17 ` Michael Paquier <michael@paquier.xyz>
2026-10-26 13:46 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2026-11-02 08:51 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification vignesh C <vignesh21@gmail.com>
0 siblings, 2 replies; 37+ messages in thread
From: Michael Paquier @ 2026-10-26 03:17 UTC (permalink / raw)
To: Greg Burd <greg@burd.me>; +Cc: pgsql-hackers; pgsql@j-davis.com; thomas.munro@gmail.com; exclusion@gmail.com; andres@anarazel.de; amit.kapila16@gmail.com; hlinnaka@iki.fi
On Fri, Oct 23, 2026 at 10:48:44AM +0000, Greg Burd wrote:
> Reviving this thread because I hit the same CRC failure on current
> master while testing something else.
Eh, and I thought that we were entirely done here. Nice
investigation.
> 1. Thomas's narrow fix (skip the image for REGBUF_NO_CHANGE) was ruled
> out because Michael's f56a9def seemed to rely on an image being present
> for a REGBUF_NO_CHANGE page. Looking again, f56a9def is on the squeeze
> *redo* path: it stops replay from setting an LSN on the write buffer
> (block 1) when that buffer turns out not to be modified. That redo code
> reads only the per-buffer data registered with XLogRegisterBufData() and
> the xl_hash_squeeze_page fields, never a full-page image, so suppressing
> the image does not affect it. The block that triggers the CRC failure
> is a different one: the primary bucket page registered as block 0 only
> to take a cleanup lock, which is never image-applied at replay.
> Suppressing its image is safe.
>
> 2. Jeff asked why hash can't just follow the rules and exclusive-lock +
> dirty the buffer. That is the better long-term answer, but it is a
> non-trivial rework of the hash cleanup/squeeze locking and does not
> back-patch cleanly. The attached fix is the minimal, back-patchable
> change and does not foreclose the rework.
I'm still wondering if this would not be the best thing long-term.
Perhaps not, so [shrug].
> Never take a full-page image for a REGBUF_NO_CHANGE buffer, even under
> XLR_CHECK_CONSISTENCY.
>
> The reasoning is the same one Thomas gave: there is nothing to
> consistency-check on a block the record does not change, and the page is
> not safe to read while assembling the record.
> verifyBackupPageConsistency() is taught to skip a registered block that
> carries no image, rather than asserting one is present (that assertion
> is what fires first on an assert build with the fix in place).
>
> This keeps REGBUF_NO_CHANGE as the single, documented marker for "pinned
> but not content-locked, not modified here" and makes its
> consistency-check behaviour match its contract.
Hmm, okay, I am fine with simpler for the sake of this proposition.
I'm finding the comments a bit over-complicated, so I've adjusted
these as of the attached. What do you think?
> I reproduced the failure with a primary plus a streaming standby,
> wal_consistency_checking='hash', and eight sessions doing:
>
> INSERT INTO h SELECT 1 FROM generate_series(1,400);
> DELETE FROM h WHERE ctid IN (SELECT ctid FROM h LIMIT 150);
>
> against a single-bucket hash index, with aggressive autovacuum. On
> unpatched master the standby dies with the CRC error within a few
> seconds, every run. With the patch, runs replayed clean and the standby
> caught up each time.
Ah, thanks for that. I also got a reproduction with these conditions.
> This still reproduces on all supported back branches (Alexander saw it
> as far back as 2018); REGBUF_NO_CHANGE exists only since 00d7fb5e (v17),
> so the back-patch needs the equivalent condition expressed without the
> flag. I can prepare those once the master approach has agreement.
Honestly, I am not convinced that it is worth bothering with the
v14~16 branches: REGBUF_NO_CHANGE does not exist there, and we would
need to identify a way to identify pin-only buffers, probably with an
exclusive lock check when a record is assembled, or something like
that. I really cannot get excited by that just for the sake of making
wal_consistency_checking able to work better for hash records there.
So let's leave it at v17~ where the regbuf flag exists.
@@ -2479,7 +2479,13 @@ verifyBackupPageConsistency(XLogReaderState *record)
continue;
}
- Assert(XLogRecHasBlockImage(record, block_id));
+ /*
+ * A block registered with REGBUF_NO_CHANGE is not modified by this
+ * record and carries no full-page image (see XLogRecordAssemble), so
+ * there is nothing to consistency-check for it. Skip it.
+ */
+ if (!XLogRecHasBlockImage(record, block_id))
+ continue;
This suggestion makes WAL replay weaker in the detection of a failure
mode attached to the record getting assembled. As this is linked to
only one specific condition in XLogRecordAssemble(), and you're
marking that in a comment, that would be hard to miss. I'm OK with
this suggestion. It's not like we should add a new marker in the
records for these purpose, the WAL bits are too precious for that.
What do you think about the comments I've touched?
--
Michael
Attachments:
v2-0001-Do-not-take-a-full-page-image-for-REGBUF_NO_CHANG.patch (text/plain, 5.3K) download
From f3ead161a0814a48b4d581495e19c17a4260d0b8 Mon Sep 17 00:00:00 2001
From: Michael Paquier <michael@paquier.xyz>
Date: Mon, 26 Oct 2026 11:59:08 +0900
Subject: [PATCH v2] Do not take a full-page image for REGBUF_NO_CHANGE buffers
A buffer registered with REGBUF_NO_CHANGE is not modified by the record
and may be held with only a pin (no content lock). The hash index code
registers the primary bucket page this way in hashbucketcleanup(),
_hash_freeovflpage() and _hash_squeezebucket(), solely to force a cleanup
lock on that block during replay.
When wal_consistency_checking includes the hash resource ,anager,
XLogRecordAssemble() included a full-page image for such a block anyway,
because XLR_CHECK_CONSISTENCY forces an image regardless of
REGBUF_NO_IMAGE. The record CRC is then computed over the image while a
concurrent backend, which legitimately holds nothing stronger than a pin
on that page, could modify it before the record is copied into the WAL
buffers.
Theis could result is an intermittent "incorrect resource manager data
checksum in record" failure on a standby.
As of this commit, never take an image for a REGBUF_NO_CHANGE buffer,
even under XLR_CHECK_CONSISTENCY. There is no need to do a consistency
check on a block not changed by a record. verifyBackupPageConsistency()
is taught to skip a registered block that carries no image rather than
asserting one should be present.
REGBUF_NO_CHANGE exists since 00d7fb5e2e39, so backpatch down to v17.
On older branches, the CRC problem can be reproduced as well, but we
lack the mechanism to check how a buffer is handled by the code
assembling a record.
Reported-by: Alexander Lakhin <exclusion@gmail.com>
Author: Greg Burd <greg@burd.me>
Diagnosed-by: Thomas Munro <thomas.munro@gmail.com>
Discussion: https://postgr.es/m/ats4pi-RM0Uom0T9@floki
Backpatch-through: 17
---
src/include/access/xloginsert.h | 4 +++-
src/backend/access/transam/README | 8 ++++++++
src/backend/access/transam/xloginsert.c | 9 ++++++++-
src/backend/access/transam/xlogrecovery.c | 7 ++++++-
4 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/src/include/access/xloginsert.h b/src/include/access/xloginsert.h
index 91dfbd5627f5..86264564ebb0 100644
--- a/src/include/access/xloginsert.h
+++ b/src/include/access/xloginsert.h
@@ -38,7 +38,9 @@
* will be skipped) */
#define REGBUF_KEEP_DATA 0x10 /* include data even if a full-page image
* is taken */
-#define REGBUF_NO_CHANGE 0x20 /* intentionally register clean buffer */
+#define REGBUF_NO_CHANGE 0x20 /* intentionally register clean buffer; no
+ * image is forced for WAL consistency
+ * checking */
/* prototypes for public functions in xloginsert.c: */
extern void XLogBeginInsert(void);
diff --git a/src/backend/access/transam/README b/src/backend/access/transam/README
index 231106270fd4..3f4fb0a167dc 100644
--- a/src/backend/access/transam/README
+++ b/src/backend/access/transam/README
@@ -586,6 +586,14 @@ void XLogRegisterBuffer(uint8 block_id, Buffer buf, uint8 flags);
XLogRegisterBufData() is included in the WAL record even if a full-page
image is taken.
+ The REGBUF_NO_CHANGE flag indicates that the buffer is registered without
+ being modified by this record, and possibly without an exclusive content
+ lock (for example, to force a cleanup lock on the block during replay).
+ WAL consistency checking does not force a full-page image for such a
+ buffer, as it may be held with only a pin and be modified concurrently
+ while the record is assembled. Callers holding only a pin should also
+ pass REGBUF_NO_IMAGE, to avoid an image for a full-page write.
+
void XLogRegisterData(const void *data, int len);
XLogRegisterData is used to include arbitrary data in the WAL record. If
diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c
index 59b0dfe436d1..c34d0c5ad838 100644
--- a/src/backend/access/transam/xloginsert.c
+++ b/src/backend/access/transam/xloginsert.c
@@ -721,8 +721,15 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
/*
* If needs_backup is true or WAL checking is enabled for current
* resource manager, log a full-page write for the current block.
+ *
+ * Do not force an image for a REGBUF_NO_CHANGE buffer. It may be
+ * held with only a pin, so the page could be modified concurrently
+ * while the record is assembled, invalidating the record CRC.
*/
- include_image = needs_backup || (info & XLR_CHECK_CONSISTENCY) != 0;
+ if (regbuf->flags & REGBUF_NO_CHANGE)
+ include_image = needs_backup;
+ else
+ include_image = needs_backup || (info & XLR_CHECK_CONSISTENCY) != 0;
if (include_image)
{
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 20be788da78c..13f15728ce6d 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -2479,7 +2479,12 @@ verifyBackupPageConsistency(XLogReaderState *record)
continue;
}
- Assert(XLogRecHasBlockImage(record, block_id));
+ /*
+ * Blocks registered with REGBUF_NO_CHANGE may have no image, see
+ * XLogRecordAssemble(). Nothing to compare for these.
+ */
+ if (!XLogRecHasBlockImage(record, block_id))
+ continue;
if (XLogRecBlockImageApply(record, block_id))
{
--
2.56.0
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2026-10-23 10:48 Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 03:17 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
@ 2026-10-26 13:46 ` Andres Freund <andres@anarazel.de>
2026-10-26 14:33 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 23:06 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
1 sibling, 2 replies; 37+ messages in thread
From: Andres Freund @ 2026-10-26 13:46 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; +Cc: Greg Burd <greg@burd.me>; pgsql-hackers; pgsql@j-davis.com; thomas.munro@gmail.com; exclusion@gmail.com; amit.kapila16@gmail.com; hlinnaka@iki.fi
Hi,
On 2026-10-26 12:17:55 +0900, Michael Paquier wrote:
> > 2. Jeff asked why hash can't just follow the rules and exclusive-lock +
> > dirty the buffer. That is the better long-term answer, but it is a
> > non-trivial rework of the hash cleanup/squeeze locking and does not
> > back-patch cleanly. The attached fix is the minimal, back-patchable
> > change and does not foreclose the rework.
>
> I'm still wondering if this would not be the best thing long-term.
> Perhaps not, so [shrug].
I frankly think it's pretty much unacceptable for a niche index like hash to
violate the rules like that. If it were btree, it'd perhaps be worthwhile to
add generic infrastructure for this, but here it doesn't seem like the juice
is worth the squeeze.
> As of this commit, never take an image for a REGBUF_NO_CHANGE buffer, even
> under XLR_CHECK_CONSISTENCY. There is no need to do a consistency check on
> a block not changed by a record. verifyBackupPageConsistency() is taught to
> skip a registered block that carries no image rather than asserting one
> should be present.
I'm not really convinced by that argument. It's probably the best answer in
the back branches, but I think we shouldn't do this in master.
Greetings,
Andres Freund
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2026-10-23 10:48 Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 03:17 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
2026-10-26 13:46 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
@ 2026-10-26 14:33 ` Greg Burd <greg@burd.me>
2026-10-26 15:15 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
1 sibling, 1 reply; 37+ messages in thread
From: Greg Burd @ 2026-10-26 14:33 UTC (permalink / raw)
To: pgsql-hackers; +Cc: andres@anarazel.de; michael@paquier.xyz; greg@burd.me; pgsql@j-davis.com; thomas.munro@gmail.com; exclusion@gmail.com; amit.kapila16@gmail.com; hlinnaka@iki.fi
On 2026-10-26 Michael Paquier wrote:
> I'm finding the comments a bit over-complicated, so I've adjusted
> these as of the attached. What do you think?
Hey Michael,
First, thanks for taking a look so fast and for offering a solid review
and revision of the patch I proposed. I'll use your wording, it is far
better than mine. The one thing I'd keep from the longer version is a
pointer from verifyBackupPageConsistency() to the exact line in
XLogRecordAssemble() that decides to omit the image, since the two have
to stay in agreement and they're far apart in the file. A half-line is
enough:
/* no image was taken (REGBUF_NO_CHANGE in XLogRecordAssemble); skip */
> So let's leave it at v17~ where the regbuf flag exists.
Agreed, drop v14-16. I'd floated the back-branch version, but the only thing
it buys there is making wal_consistency_checking='hash' not crash a standby,
and on reflection that's not worth inventing a pin-only detection path those
branches don't otherwise need.
On 2026-10-26 Andres Freund wrote:
> I frankly think it's pretty much unacceptable for a niche index like hash
> to violate the rules like that.
> [...]
> It's probably the best answer in the back branches, but I think we
> shouldn't do this in master.
Hey Andres,
Thanks for taking the time to review, I'm curious why you used the term
"niche" with hash indexes. Not related to this topic, just an aside.
You're right, the real problem is hash CRCs a page it holds only a pin on, so
another backend can change it under the record. The clean fix is to make the
three call sites (hashbucketcleanup, _hash_freeovflpage, _hash_squeezebucket)
stop reading a page they don't content-lock and either take the buffer the
normal way, or follow the XLogSaveBufferForHint() protocol Jeff pointed at.
Where I'd push back is on making that the gate for master while the standby
crash stays unfixed. Two things make me want the small fix in master too, not
only the back branches:
1. REGBUF_NO_CHANGE's contract already is "pinned, not content-locked, not
modified here". Taking a full-page image of such a block under
XLR_CHECK_CONSISTENCY contradicts that contract on its own terms:
there's nothing to consistency-check on a block the record doesn't
change, and the page isn't safe to read while assembling the record.
So skipping the image isn't only a hash workaround it makes the
consistency-check path honor the flag's definition. Any future code
that legitimately registers a pin-only block hits the same assertion
today.
2. If master keeps taking the image and the hash rework lands later, the
rework has to touch the same three sites anyway, and in the meantime
master is the one branch where wal_consistency_checking='hash' faults.
Fixing the flag's behaviour in master and doing the hash rework as a
follow-up are not in tension, the rework doesn't depend on the image
still being taken.
Concretely, here's what I propose:
- master and v17+: the minimal fix (skip the image for REGBUF_NO_CHANGE,
with Michael's comments). This stops the standby crash on every branch
that has the flag and makes the consistency check match the contract.
- master, separate patch: make hash stop modifying pin-only buffers at the
three sites, so hash follows the buffer rules and the REGBUF_NO_CHANGE |
REGBUF_NO_IMAGE dance for "just force a cleanup lock" is no longer
needed. I'm willing to write this; it's the non-trivial part, and I'd
rather it be reviewed on its own than bundled with the crash fix.
If you'd still rather master not carry the flag-level fix at all and wait for
the hash rework, I can live with that but then I'd want the rework to be the
thing we track for master now, not a someday item, because the crash is live on
master today. Which of those do you prefer?
I'll hold the back-branch patches and post a v-next of the master patch with
Michael's comments once we've settled master-only-rework vs
flag-fix-plus-rework.
best,
-greg
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2026-10-23 10:48 Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 03:17 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
2026-10-26 13:46 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2026-10-26 14:33 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
@ 2026-10-26 15:15 ` Andres Freund <andres@anarazel.de>
2026-10-26 15:38 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 18:08 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification shihao zhong <zhong950419@gmail.com>
2026-10-29 20:49 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Jeff Davis <pgsql@j-davis.com>
0 siblings, 3 replies; 37+ messages in thread
From: Andres Freund @ 2026-10-26 15:15 UTC (permalink / raw)
To: Greg Burd <greg@burd.me>; pgsql-hackers; +Cc: michael@paquier.xyz; greg@burd.me; pgsql@j-davis.com; thomas.munro@gmail.com; exclusion@gmail.com; amit.kapila16@gmail.com; hlinnaka@iki.fi
Hi,
On October 26, 2026 10:33:16 AM EDT, Greg Burd <greg@burd.me> wrote:
>On 2026-10-26 Andres Freund wrote:
>> I frankly think it's pretty much unacceptable for a niche index like hash
>> to violate the rules like that.
>> [...]
>> It's probably the best answer in the back branches, but I think we
>> shouldn't do this in master.
>
>Thanks for taking the time to review, I'm curious why you used the term
>"niche" with hash indexes. Not related to this topic, just an aside.
I think they're almost unused and don't offer enough advantage over btree (and perform catastrophically bad in many cases). Instead of making them WAL logged a few years back; we should have just ripped them out.
The advantage hash does have, i.e. large key handling, would have better been addressed by adding support to transparently btree indexing a hash of the key + recheck.
Greetings,
Andres
--
Sent from my phone. Please excuse my brevity.
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2026-10-23 10:48 Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 03:17 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
2026-10-26 13:46 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2026-10-26 14:33 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 15:15 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
@ 2026-10-26 15:38 ` Greg Burd <greg@burd.me>
2 siblings, 0 replies; 37+ messages in thread
From: Greg Burd @ 2026-10-26 15:38 UTC (permalink / raw)
To: pgsql-hackers; +Cc: andres@anarazel.de; michael@paquier.xyz; pgsql@j-davis.com; thomas.munro@gmail.com; exclusion@gmail.com; amit.kapila16@gmail.com; hlinnaka@iki.fi
On 2026-10-26 Andres Freund wrote:
> I think they're almost unused and don't offer enough advantage over btree
> (and perform catastrophically bad in many cases). Instead of making them WAL
> logged a few years back; we should have just ripped them out.
Fair, whether hash earns its place is a bigger conversation than this
bug. I'll just note one data point from the other thread I have open: a
good part of the "catastrophically bad in many cases" is the metapage
tuple counter serialising every insert on one buffer, and that looks
removable. Inserts stop touching the metapage on the common path and
hash then scales like btree on a concurrent insert workload in my
measurements. That doesn't change your conclusion about large-key
handling, but it does move some of the "performs badly" into "performed
badly".
> The advantage hash does have, i.e. large key handling, would have better been
> addressed by adding support to transparently btree indexing a hash of the key
> + recheck.
No disagreement that that would have been the better design. It's not
where we are, though, and ripping out a shipped, WAL-logged,
user-visible AM is its own multi-release project.
Which leaves the thing this thread actually needs a decision on,
independent of hash's long-term fate: master faults a standby under
wal_consistency_checking='hash' today. The one-line fix (skip the
full-page image for a REGBUF_NO_CHANGE block, which contradicts the
flag's own contract to take) stops that and Michael's OK with it for
v17+. You'd said you'd rather master wait for the proper hash rework.
I'm fine either way, but if master isn't getting the flag-level fix now,
I'd like the rework to be the tracked item for master rather than a
someday, the crash is live on master. So: flag fix in master now plus
rework as follow-up, or rework-only for master?
I'll build whichever, I just don't want it to stall into neither.
best,
-greg
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2026-10-23 10:48 Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 03:17 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
2026-10-26 13:46 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2026-10-26 14:33 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 15:15 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
@ 2026-10-26 18:08 ` shihao zhong <zhong950419@gmail.com>
2026-10-27 13:04 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2 siblings, 1 reply; 37+ messages in thread
From: shihao zhong @ 2026-10-26 18:08 UTC (permalink / raw)
To: Andres Freund <andres@anarazel.de>; +Cc: Greg Burd <greg@burd.me>; pgsql-hackers; michael@paquier.xyz; pgsql@j-davis.com; thomas.munro@gmail.com; exclusion@gmail.com; amit.kapila16@gmail.com; hlinnaka@iki.fi
Hi Andres and Greg,
> I think they're almost unused and don't offer enough advantage over btree
I largely agree with this. In my experience, B-tree accounts for 95%+ of
indexes, and all other access methods combined make up only a
small fraction. But I do see quite a few hash index users.
> we should have just ripped them out.
I have mixed feelings on this. On one hand, hash is probably the least used
"general-purpose" index since its use case overlaps directly with B-tree,
whereas GiST, SP-GiST, and BRIN exist for specialized data types or access
patterns that B-tree can't handle. On the other hand, in practice I still
see
hash indexes used at least as often as GiST, BRIN, or SP-GiST.
I suspect part of the low adoption is historical baggage from being
unlogged prior to old version, which gave hash indexes a bad reputation in
the
community, it also miss some features for general OLTP workloads
I feel there is plenty of room for improvement there.
> The advantage hash does have, i.e. large key handling, would have better
been
> addressed by adding support to transparently btree indexing a hash of the
key + recheck.
That's an interesting point. But I think users can do that today with
expression
index right?
Thanks,
Shihao
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2026-10-23 10:48 Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 03:17 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
2026-10-26 13:46 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2026-10-26 14:33 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 15:15 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2026-10-26 18:08 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification shihao zhong <zhong950419@gmail.com>
@ 2026-10-27 13:04 ` Greg Burd <greg@burd.me>
2026-10-27 14:04 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification shihao zhong <zhong950419@gmail.com>
0 siblings, 1 reply; 37+ messages in thread
From: Greg Burd @ 2026-10-27 13:04 UTC (permalink / raw)
To: pgsql-hackers; +Cc: zhong950419@gmail.com; andres@anarazel.de; greg@burd.me; michael@paquier.xyz; pgsql@j-davis.com; thomas.munro@gmail.com; exclusion@gmail.com; amit.kapila16@gmail.com; hlinnaka@iki.fi
On Mon, 26 Oct 2026 14:08:29 -0400, shihao zhong <zhong950419@gmail.com> wrote:
> Hi Andres and Greg,
>
> > I think they're almost unused and don't offer enough advantage over btree
>
> I largely agree with this. In my experience, B-tree accounts for 95%+ of
> indexes, and all other access methods combined make up only a
> small fraction. But I do see quite a few hash index users.
While I agree that the vast majority of users rightly default to the
BTREE index I don't find that a compelling reason to drop HASH. I see
that as a challenge, maybe HASH isn't used because it is not as well
maintained as BTREE and needs some attention [0]?
> > we should have just ripped them out.
>
> I have mixed feelings on this.
I think this would invite further specialization of code outside nbtree
into shapes that only support nbtree reducing the ability to innovate
with other table and index AMs.
Sure there is GIN, GiST, BRIN, etc. but IMO hash represents a quadrant
of access patterns that we should support, and our code there today
isn't inspiring many to give it a look even for use cases that fit that
pattern well. That's a signal to innovate, not remove code.
We have this issue today with HEAP, because we only have one table AM in
core things are simpler to maintain but it is also easier for heap-isms
to leak outside the table AM boundaries in the name of performance or
other goals.
IMO this is a long-term philosophical question for Postgres; is it
extensible or is it highly opinionated and specialized?
> On one hand, hash is probably the least used
> "general-purpose" index since its use case overlaps directly with B-tree,
> whereas GiST, SP-GiST, and BRIN exist for specialized data types or access
> patterns that B-tree can't handle. On the other hand, in practice I still
> see hash indexes used at least as often as GiST, BRIN, or SP-GiST.
>
> I suspect part of the low adoption is historical baggage from being
> unlogged prior to old version, which gave hash indexes a bad reputation in
> the community, it also miss some features for general OLTP workloads
>
> I feel there is plenty of room for improvement there.
I agree that there is historical baggage, performance, and possibly simple
knowledge gaps that push the adoption toward BTREE.
> > The advantage hash does have, i.e. large key handling, would have better
> > been addressed by adding support to transparently btree indexing a hash
> > of the key + recheck.
>
> That's an interesting point. But I think users can do that today with
> expression index right?
Expression indexes prevent HOT updates, so maybe you could but at what
cost?
> Thanks,
> Shihao
best.
-greg
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2026-10-23 10:48 Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 03:17 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
2026-10-26 13:46 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2026-10-26 14:33 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 15:15 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2026-10-26 18:08 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification shihao zhong <zhong950419@gmail.com>
2026-10-27 13:04 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
@ 2026-10-27 14:04 ` shihao zhong <zhong950419@gmail.com>
2026-10-27 14:32 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-29 20:33 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Jeff Davis <pgsql@j-davis.com>
0 siblings, 2 replies; 37+ messages in thread
From: shihao zhong @ 2026-10-27 14:04 UTC (permalink / raw)
To: Greg Burd <greg@burd.me>; +Cc: pgsql-hackers; andres@anarazel.de; michael@paquier.xyz; pgsql@j-davis.com; thomas.munro@gmail.com; exclusion@gmail.com; amit.kapila16@gmail.com; hlinnaka@iki.fi
Hi Greg,
> That's a signal to innovate, not remove code.
I agree with that and I would like to spend some time to modernize hash,
I will start looking after the PG19 release and happy to review any of your
hash changes.
> Expression indexes prevent HOT updates, so maybe you could but at what
> cost?
Haven't really tested that, just some wild thinking, but I think hash index
also
have similar limitations.
Thanks,
Shihao
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2026-10-23 10:48 Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 03:17 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
2026-10-26 13:46 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2026-10-26 14:33 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 15:15 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2026-10-26 18:08 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification shihao zhong <zhong950419@gmail.com>
2026-10-27 13:04 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-27 14:04 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification shihao zhong <zhong950419@gmail.com>
@ 2026-10-27 14:32 ` Greg Burd <greg@burd.me>
1 sibling, 0 replies; 37+ messages in thread
From: Greg Burd @ 2026-10-27 14:32 UTC (permalink / raw)
To: shihao zhong <zhong950419@gmail.com>; +Cc: pgsql-hackers; andres@anarazel.de; michael@paquier.xyz; pgsql@j-davis.com; thomas.munro@gmail.com; exclusion@gmail.com; amit.kapila16@gmail.com; hlinnaka@iki.fi
On Tuesday, October 27th, 2026 at 10:05 AM, shihao zhong <zhong950419@gmail.com> wrote:
> Hi Greg,
> > That's a signal to innovate, not remove code.
>
> I agree with that and I would like to spend some time to modernize hash,
> I will start looking after the PG19 release and happy to review any of your
> hash changes.
Sounds like a plan to me.
> > Expression indexes prevent HOT updates, so maybe you could but at what
> > cost?
>
> Haven't really tested that, just some wild thinking, but I think hash index also
> have similar limitations.
This is a heap limitation, and update to a row where there is an expression index
that has a column reference which was modified prevents the HOT update even if
that expression didn't result in a material change to the index key.
> Thanks,
> Shihao
-greg
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2026-10-23 10:48 Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 03:17 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
2026-10-26 13:46 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2026-10-26 14:33 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 15:15 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2026-10-26 18:08 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification shihao zhong <zhong950419@gmail.com>
2026-10-27 13:04 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-27 14:04 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification shihao zhong <zhong950419@gmail.com>
@ 2026-10-29 20:33 ` Jeff Davis <pgsql@j-davis.com>
1 sibling, 0 replies; 37+ messages in thread
From: Jeff Davis @ 2026-10-29 20:33 UTC (permalink / raw)
To: shihao zhong <zhong950419@gmail.com>; Greg Burd <greg@burd.me>; +Cc: pgsql-hackers; andres@anarazel.de; michael@paquier.xyz; thomas.munro@gmail.com; exclusion@gmail.com; amit.kapila16@gmail.com; hlinnaka@iki.fi
On Tue, 2026-10-27 at 10:04 -0400, shihao zhong wrote:
> I agree with that and I would like to spend some time to
> modernize hash,
There have been prior efforts in this area, such as WAL logging, under
the same assumption: that people don't use hash indexes, but would if
we put more work into them.
At this point, the bar is quite high for convincing people to use them.
Being slightly better in some cases is probably not enough to get
attention. As Andres said, the long keys problem with btrees is
incidental, and can be solved other ways. Also, btree indexes aren't
standing still, which makes it even harder to make the case.
Regards,
Jeff Davis
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2026-10-23 10:48 Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 03:17 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
2026-10-26 13:46 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2026-10-26 14:33 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 15:15 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
@ 2026-10-29 20:49 ` Jeff Davis <pgsql@j-davis.com>
2026-10-30 02:51 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification shihao zhong <zhong950419@gmail.com>
2 siblings, 1 reply; 37+ messages in thread
From: Jeff Davis @ 2026-10-29 20:49 UTC (permalink / raw)
To: Andres Freund <andres@anarazel.de>; Greg Burd <greg@burd.me>; pgsql-hackers; +Cc: michael@paquier.xyz; thomas.munro@gmail.com; exclusion@gmail.com; amit.kapila16@gmail.com; hlinnaka@iki.fi
On Mon, 2026-10-26 at 11:15 -0400, Andres Freund wrote:
> The advantage hash does have, i.e. large key handling, would have
> better been addressed by adding support to transparently btree
> indexing a hash of the key + recheck.
In theory we could generalize this. We can take any predicate x=a,
create a new implied predicate f(x)=f(a), and then use a functional
index on f(x). (Assuming f() satisfies the right properties and
equality means the very same value.)
The planner wouldn't need any extra logic to recheck, because the x=a
predicate is still there. If there's no index on (x) but there's an
index on (f(x)), then we can see if f is a member of a hash opclass, or
if it's IMMUTABLE & LEAKPROOF, and I think that's enough.
Regards,
Jeff Davis
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2026-10-23 10:48 Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 03:17 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
2026-10-26 13:46 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2026-10-26 14:33 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 15:15 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2026-10-29 20:49 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Jeff Davis <pgsql@j-davis.com>
@ 2026-10-30 02:51 ` shihao zhong <zhong950419@gmail.com>
2026-10-30 19:13 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Jeff Davis <pgsql@j-davis.com>
0 siblings, 1 reply; 37+ messages in thread
From: shihao zhong @ 2026-10-30 02:51 UTC (permalink / raw)
To: Jeff Davis <pgsql@j-davis.com>; +Cc: Andres Freund <andres@anarazel.de>; Greg Burd <greg@burd.me>; pgsql-hackers; michael@paquier.xyz; thomas.munro@gmail.com; exclusion@gmail.com; amit.kapila16@gmail.com; hlinnaka@iki.fi
Hi Jeff,
> At this point, the bar is quite high for convincing people to use them.
I agree with that, but I think there are still a decent number of users
who are using hash indexes for different reasons.
I also did some research this afternoon and found that Postgres is the
only mainline DB that still provides an on-disk hash index. So either
we are wrong, or that could be our competitive edge on certain use
cases. I am personally not an expert on hash indexes, so I am not sure
which one I will end up with.
Andres said, the long keys problem with btrees is
> incidental, and can be solved other ways.
Looks like this is an interesting problem. I do agree that if there is
any potential optimization for btree, we should take it all. If nobody
volunteers, I can create a different thread and create a POC for it
after 19 GAed.
> If there's no index on (x) but there's an index on (f(x)), then we can
> see if f is a member of a hash opclass, or if it's IMMUTABLE &
> LEAKPROOF, and I think that's enough.
I am not sure. I know some types' = has special logic, where it may not
mean they are the same.
For example, 'ABC' = 'abc' is true
with a case-insensitive collation. But md5() gives different results.
Thanks,
Shihao
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2026-10-23 10:48 Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 03:17 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
2026-10-26 13:46 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2026-10-26 14:33 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 15:15 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2026-10-29 20:49 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Jeff Davis <pgsql@j-davis.com>
2026-10-30 02:51 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification shihao zhong <zhong950419@gmail.com>
@ 2026-10-30 19:13 ` Jeff Davis <pgsql@j-davis.com>
0 siblings, 0 replies; 37+ messages in thread
From: Jeff Davis @ 2026-10-30 19:13 UTC (permalink / raw)
To: shihao zhong <zhong950419@gmail.com>; +Cc: Andres Freund <andres@anarazel.de>; Greg Burd <greg@burd.me>; pgsql-hackers; michael@paquier.xyz; thomas.munro@gmail.com; exclusion@gmail.com; amit.kapila16@gmail.com; hlinnaka@iki.fi
On Thu, 2026-10-29 at 22:51 -0400, shihao zhong wrote:
> I agree with that, but I think there are still a decent number of
> users
> who are using hash indexes for different reasons.
...
> Looks like this is an interesting problem. I do agree that if there
> is
> any potential optimization for btree, we should take it all. If
> nobody
> volunteers, I can create a different thread and create a POC for it
> after 19 GAed.
Yes, that makes sense to me. If you think there's benefit to be had,
please go ahead in a new thread.
>
> I am not sure. I know some types' = has special logic, where it may
> not
> mean they are the same.
>
> For example, 'ABC' = 'abc' is true
> with a case-insensitive collation. But md5() gives different results.
Right, there are a few details to work out. But I do think there's room
to solve this in the optimizer rather than add more special cases to
index DDL and the AMs.
We could start by saying it only works if f() is part of a hash
opclass, or something.
Regards,
Jeff Davis
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2026-10-23 10:48 Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 03:17 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
2026-10-26 13:46 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
@ 2026-10-26 23:06 ` Michael Paquier <michael@paquier.xyz>
2026-10-27 13:54 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-28 13:29 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-28 15:57 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
1 sibling, 3 replies; 37+ messages in thread
From: Michael Paquier @ 2026-10-26 23:06 UTC (permalink / raw)
To: Andres Freund <andres@anarazel.de>; +Cc: Greg Burd <greg@burd.me>; pgsql-hackers; pgsql@j-davis.com; thomas.munro@gmail.com; exclusion@gmail.com; amit.kapila16@gmail.com; hlinnaka@iki.fi
On Mon, Oct 26, 2026 at 09:46:18AM -0400, Andres Freund wrote:
> I frankly think it's pretty much unacceptable for a niche index like hash to
> violate the rules like that. If it were btree, it'd perhaps be worthwhile to
> add generic infrastructure for this, but here it doesn't seem like the juice
> is worth the squeeze.
I'm definitely not convinced that hash is a sufficient argument for
having more infrastructure. What this is telling us here is the
contrary: we should have less infrastructure. So I'd love to be able
to put REGBUF_NO_CHANGE in the garbage bin and have an assert in the
replay code instead of silently ignoring a case.
> I'm not really convinced by that argument. It's probably the best answer in
> the back branches, but I think we shouldn't do this in master.
I'm not sure that I can side with your argument here. Doing nothing
on master means that we're still open to the CRC problem until we
decide to fix hash, so it still looks like a problem that needs to be
tackled in three steps:
- Avoid the CRC problem down to v17, including HEAD.
- Address hash to avoid the rule breakage.
- Lift the check in replay for wal_consistency_checking (re-add the
assert) and push REGBUF_NO_CHANGE into orbit.
There is nothing more permanent than a temporary fix, as some say,
but I'd like to trust in something happening for hash. I'm not
planning to code that myself, though, but if somebody is willing to
work that, be it with an LLM, I would read the code.
That's just to say that I don't see a downside with including HEAD in
step 1.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2026-10-23 10:48 Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 03:17 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
2026-10-26 13:46 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2026-10-26 23:06 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
@ 2026-10-27 13:54 ` Greg Burd <greg@burd.me>
2026-10-28 14:54 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification vignesh C <vignesh21@gmail.com>
2 siblings, 1 reply; 37+ messages in thread
From: Greg Burd @ 2026-10-27 13:54 UTC (permalink / raw)
To: pgsql-hackers; +Cc: michael@paquier.xyz; andres@anarazel.de; pgsql@j-davis.com; thomas.munro@gmail.com; exclusion@gmail.com; amit.kapila16@gmail.com; hlinnaka@iki.fi
On Tue, 27 Oct 2026 08:06:48 +0900, Michael Paquier <michael@paquier.xyz> wrote:
> it still looks like a problem that needs to be tackled in three steps:
> - Avoid the CRC problem down to v17, including HEAD.
> - Address hash to avoid the rule breakage.
> - Lift the check in replay for wal_consistency_checking (re-add the
> assert) and push REGBUF_NO_CHANGE into orbit.
> [...] if somebody is willing to work that, be it with an LLM, I would
> read the code.
That plan works for me, and I'll take the hash rework (step 2).
Step 1 (down to v17, including HEAD): the flag-level fix we discussed,
with your comment wording. I'll post it as the next version shortly.
The one line I'd keep is the pointer from verifyBackupPageConsistency()
back to XLogRecordAssemble(), since the two have to stay in agreement
and they're far apart in the file.
Step 2 (make hash stop breaking the rule): the three sites that register
a pin-only primary/bucket page purely to force a replay cleanup lock
(hashbucketcleanup, _hash_freeovflpage, _hash_squeezebucket). The
tricky part isn't locking the page, it's doing so without losing the
replay-cleanup-lock behaviour the registration exists to produce, so the
standby still serialises against scans the same way. The
XLogSaveBufferForHint() protocol Jeff pointed at in 2024 is the model
I'll start from -- it already copes with WAL-logging a page that isn't
held exclusively. I'll post that on this thread for review before
worrying about step 3; once it's in, step 3 (re-add the assert, remove
REGBUF_NO_CHANGE) falls out.
> There is nothing more permanent than a temporary fix [...] but I'd like
> to trust in something happening for hash.
Too true!
On 2026-10-26 shihao zhong wrote:
> [btree indexing a hash of the key + recheck] users can do that today with
> expression index right?
Something else occured to me on this, the gap is the interesting bit.
You can do:
CREATE INDEX ON t (hashtext(col)) and then query
WHERE hashtext(col) = hashtext('x') AND col = 'x'
but you have to write the hash and the recheck yourself in every query,
and the planner won't use that index for a plain col = 'x'.
What Andres described is the planner doing that transparently for col =
'x' against a normal-looking index, which the expression-index approach
doesn't give you, and HOT is out of the question [0]. So it's a manual
workaround today, not the transparent feature. (Orthogonal to this
thread; just answering.)
best,
-greg
[0] https://postgr.es/m/78574B24-BE0A-42C5-8075-3FA9FA63B8FC@amazon.com
Attachments:
v1-0001-Don-t-take-a-full-page-image-for-REGBUF_NO_CHANGE.patch (text/plain, 6.0K) download
From 09a645463af50abdfb3b9ea20decee42ff88d4b1 Mon Sep 17 00:00:00 2001
From: Greg Burd <greg@burd.me>
Date: Thu, 22 Oct 2026 14:43:17 -0400
Subject: [PATCH v1] Don't take a full-page image for REGBUF_NO_CHANGE buffers
A buffer registered with REGBUF_NO_CHANGE is not modified by the record
and may be held with only a pin (no content lock). The hash index code
registers the primary bucket page this way in hashbucketcleanup(),
_hash_freeovflpage() and _hash_squeezebucket(), solely to force a cleanup
lock on that block during replay.
When wal_consistency_checking includes the hash RM, XLogRecordAssemble()
included a full-page image for such a block anyway, because
XLR_CHECK_CONSISTENCY forces an image regardless of REGBUF_NO_IMAGE. The
record CRC is then computed over the image while a concurrent backend,
which legitimately holds nothing stronger than a pin on that page, is
free to modify it before the record is copied into the WAL buffers. The
result is an intermittent "incorrect resource manager data checksum in
record" failure on a standby (or under a crash-recovery consistency
check), reproducible on the buildfarm with wal_consistency_checking and
concurrent inserts plus autovacuum on a hash index.
Fix by never taking an image for a REGBUF_NO_CHANGE buffer, even under
XLR_CHECK_CONSISTENCY. There is nothing to consistency-check on a block
the record does not change, and the page is not safe to read while
assembling the record. verifyBackupPageConsistency() is taught to skip a
registered block that carries no image rather than asserting one is
present.
Reported-by: Alexander Lakhin
Diagnosed-by: Thomas Munro
Discussion: https://postgr.es/m/055bb33c-bccc-bc1d-c2f8-8598534448ac@gmail.com
---
src/backend/access/transam/README | 9 +++++++++
src/backend/access/transam/xloginsert.c | 15 ++++++++++++++-
src/backend/access/transam/xlogrecovery.c | 8 +++++++-
src/include/access/xloginsert.h | 7 ++++++-
4 files changed, 36 insertions(+), 3 deletions(-)
diff --git a/src/backend/access/transam/README b/src/backend/access/transam/README
index 231106270fd..138c4c0ada6 100644
--- a/src/backend/access/transam/README
+++ b/src/backend/access/transam/README
@@ -586,6 +586,15 @@ void XLogRegisterBuffer(uint8 block_id, Buffer buf, uint8 flags);
XLogRegisterBufData() is included in the WAL record even if a full-page
image is taken.
+ The REGBUF_NO_CHANGE flag indicates that the buffer is registered without
+ being modified by this record, and possibly without an exclusive content
+ lock (for example, to force a cleanup lock on the block during replay).
+ Such a buffer never has a full-page image taken, not even when WAL
+ consistency checking is enabled: its contents may change concurrently
+ while the record is assembled, which would compute the record CRC over
+ data a concurrent backend can still modify, and there is nothing to
+ consistency-check on a block the record does not change.
+
void XLogRegisterData(const void *data, int len);
XLogRegisterData is used to include arbitrary data in the WAL record. If
diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c
index 59b0dfe436d..c3c95f89276 100644
--- a/src/backend/access/transam/xloginsert.c
+++ b/src/backend/access/transam/xloginsert.c
@@ -721,8 +721,21 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
/*
* If needs_backup is true or WAL checking is enabled for current
* resource manager, log a full-page write for the current block.
+ *
+ * However, a buffer registered with REGBUF_NO_CHANGE is not modified
+ * by this record and may be held with only a pin (no content lock),
+ * so its contents could change under us while we assemble the record.
+ * Including such a page would compute the record CRC over data that a
+ * concurrent backend can modify before the record is copied into the
+ * WAL buffers, producing a spurious "incorrect resource manager data
+ * checksum" failure. These blocks are registered only to force a
+ * cleanup lock during replay, so there is nothing to consistency-check
+ * anyway; never take an image for them.
*/
- include_image = needs_backup || (info & XLR_CHECK_CONSISTENCY) != 0;
+ if (regbuf->flags & REGBUF_NO_CHANGE)
+ include_image = needs_backup;
+ else
+ include_image = needs_backup || (info & XLR_CHECK_CONSISTENCY) != 0;
if (include_image)
{
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 20be788da78..52cb5cdc0a1 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -2479,7 +2479,13 @@ verifyBackupPageConsistency(XLogReaderState *record)
continue;
}
- Assert(XLogRecHasBlockImage(record, block_id));
+ /*
+ * A block registered with REGBUF_NO_CHANGE is not modified by this
+ * record and carries no full-page image (see XLogRecordAssemble), so
+ * there is nothing to consistency-check for it. Skip it.
+ */
+ if (!XLogRecHasBlockImage(record, block_id))
+ continue;
if (XLogRecBlockImageApply(record, block_id))
{
diff --git a/src/include/access/xloginsert.h b/src/include/access/xloginsert.h
index 91dfbd5627f..6ae2692d5b9 100644
--- a/src/include/access/xloginsert.h
+++ b/src/include/access/xloginsert.h
@@ -38,7 +38,12 @@
* will be skipped) */
#define REGBUF_KEEP_DATA 0x10 /* include data even if a full-page image
* is taken */
-#define REGBUF_NO_CHANGE 0x20 /* intentionally register clean buffer */
+#define REGBUF_NO_CHANGE 0x20 /* intentionally register clean buffer;
+ * suppresses the full-page image that
+ * XLR_CHECK_CONSISTENCY would otherwise
+ * take, since the page is not changed by
+ * this record and may not be
+ * content-locked */
/* prototypes for public functions in xloginsert.c: */
extern void XLogBeginInsert(void);
--
2.50.1
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2026-10-23 10:48 Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 03:17 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
2026-10-26 13:46 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2026-10-26 23:06 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
2026-10-27 13:54 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
@ 2026-10-28 14:54 ` vignesh C <vignesh21@gmail.com>
2026-11-02 06:04 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification vignesh C <vignesh21@gmail.com>
0 siblings, 1 reply; 37+ messages in thread
From: vignesh C @ 2026-10-28 14:54 UTC (permalink / raw)
To: Greg Burd <greg@burd.me>; +Cc: pgsql-hackers; michael@paquier.xyz; andres@anarazel.de; pgsql@j-davis.com; thomas.munro@gmail.com; exclusion@gmail.com; amit.kapila16@gmail.com; hlinnaka@iki.fi
On Tue, 27 Oct 2026 at 19:25, Greg Burd <greg@burd.me> wrote:
>
> On Tue, 27 Oct 2026 08:06:48 +0900, Michael Paquier <michael@paquier.xyz> wrote:
> > it still looks like a problem that needs to be tackled in three steps:
> > - Avoid the CRC problem down to v17, including HEAD.
> > - Address hash to avoid the rule breakage.
> > - Lift the check in replay for wal_consistency_checking (re-add the
> > assert) and push REGBUF_NO_CHANGE into orbit.
> > [...] if somebody is willing to work that, be it with an LLM, I would
> > read the code.
>
> That plan works for me, and I'll take the hash rework (step 2).
>
> Step 1 (down to v17, including HEAD): the flag-level fix we discussed,
> with your comment wording. I'll post it as the next version shortly.
> The one line I'd keep is the pointer from verifyBackupPageConsistency()
> back to XLogRecordAssemble(), since the two have to stay in agreement
> and they're far apart in the file.
Thanks for working on this. These comments are on the step 1 patch
(v1-0001, "Don't take a full-page image for REGBUF_NO_CHANGE
buffers").
I could reproduce the problem consistently with a VACUUM on a table
with a hash index and a concurrent INSERT, with
wal_consistency_checking = 'hash'. The test is attached; it needs a
test-only injection point after the CRC loop in XLogRecordAssemble().
Your step 1 patch fixes it.
Few comments:
1. The README, the macro comment, the code comment and the commit
message say such a buffer "never has a full-page image taken". The
code is include_image = needs_backup, so an image is still taken when
needs_backup is true. For example, _hash_freeovflpage() registers the
write buffer with REGBUF_STANDARD | REGBUF_NO_CHANGE, without
REGBUF_NO_IMAGE, when the primary bucket page is the write page and no
tuples are moved onto it. After a checkpoint, that record carries an
ordinary FPI of the page.
+ The REGBUF_NO_CHANGE flag indicates that the buffer is registered without
+ being modified by this record, and possibly without an exclusive content
+ lock (for example, to force a cleanup lock on the block during replay).
+ Such a buffer never has a full-page image taken, not even when WAL
+ consistency checking is enabled: its contents may change concurrently
Is this ok, or should we mention like "no consistency-check image"
2. The patch does not apply to REL_17 (the README hunk fails), so a
separate patch is needed for that branch.
Regards,
Vignesh
Attachments:
0001-Test-for-hash-index-corruption-issue.patch (application/octet-stream, 9.6K) download
From 7757e38a0f020fd3d93b380aa9242beb666c875c Mon Sep 17 00:00:00 2001
From: Vignesh C <vignesh21@gmail.com>
Date: Wed, 28 Oct 2026 20:12:17 +0530
Subject: [PATCH] Test for hash index corruption issue.
Test for hash index corruption issue.
---
src/backend/access/transam/xloginsert.c | 23 +++
src/test/recovery/Makefile | 1 +
src/test/recovery/meson.build | 1 +
.../recovery/t/061_hash_vacuum_insert_crc.pl | 160 ++++++++++++++++++
4 files changed, 185 insertions(+)
create mode 100644 src/test/recovery/t/061_hash_vacuum_insert_crc.pl
diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c
index c3c95f89276..0c5bac6523c 100644
--- a/src/backend/access/transam/xloginsert.c
+++ b/src/backend/access/transam/xloginsert.c
@@ -39,6 +39,7 @@
#include "replication/origin.h"
#include "storage/bufmgr.h"
#include "storage/proc.h"
+#include "utils/injection_point.h"
#include "utils/memutils.h"
#include "utils/pgstat_internal.h"
#include "utils/rel.h"
@@ -630,6 +631,7 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
XLogRecData *rdt;
uint64 total_len = 0;
int block_id;
+ int nochange_bufs = 0;
pg_crc32c rdata_crc;
registered_buffer *prev_regbuf = NULL;
XLogRecData *rdt_datas_last;
@@ -737,6 +739,9 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
else
include_image = needs_backup || (info & XLR_CHECK_CONSISTENCY) != 0;
+ if ((regbuf->flags & REGBUF_NO_CHANGE) != 0)
+ nochange_bufs++;
+
if (include_image)
{
const PageData *page = regbuf->page;
@@ -999,6 +1004,24 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
for (rdt = hdr_rdt.next; rdt != NULL; rdt = rdt->next)
COMP_CRC32C(rdata_crc, rdt->data, rdt->len);
+ /*
+ * Test hook: lets a test change a buffer after the CRC was computed but
+ * before the record is copied into the WAL buffers. The argument names
+ * the record as "rmid/info/nochange_bufs" so that a test can pick one
+ * kind of record without waiting on every record. This runs in critical
+ * sections, so it must not allocate; it only fires in a backend that
+ * loaded the point beforehand.
+ */
+#ifdef USE_INJECTION_POINTS
+ {
+ char pointarg[24];
+
+ snprintf(pointarg, sizeof(pointarg), "%d/%02X/%d",
+ rmid, info, nochange_bufs);
+ INJECTION_POINT_CACHED("xlog-assemble-after-crc", pointarg);
+ }
+#endif
+
/*
* Ensure that the XLogRecord is not too large.
*
diff --git a/src/test/recovery/Makefile b/src/test/recovery/Makefile
index 9c4102b6b2c..456c211ea62 100644
--- a/src/test/recovery/Makefile
+++ b/src/test/recovery/Makefile
@@ -10,6 +10,7 @@
#-------------------------------------------------------------------------
EXTRA_INSTALL=contrib/pg_prewarm \
+ contrib/pg_visibility \
contrib/pg_stat_statements \
contrib/test_decoding \
src/test/modules/injection_points \
diff --git a/src/test/recovery/meson.build b/src/test/recovery/meson.build
index b6ac9dd07a7..5051031df56 100644
--- a/src/test/recovery/meson.build
+++ b/src/test/recovery/meson.build
@@ -69,6 +69,7 @@ tests += {
't/058_shutdown_crash_restart.pl',
't/059_remote_apply_status_interval.pl',
't/060_multixact_crashed_updater.pl',
+ 't/061_hash_vacuum_insert_crc.pl',
],
},
}
diff --git a/src/test/recovery/t/061_hash_vacuum_insert_crc.pl b/src/test/recovery/t/061_hash_vacuum_insert_crc.pl
new file mode 100644
index 00000000000..d1450130d6c
--- /dev/null
+++ b/src/test/recovery/t/061_hash_vacuum_insert_crc.pl
@@ -0,0 +1,160 @@
+# Copyright (c) 2026, PostgreSQL Global Development Group
+
+# Test that the WAL record written by hash index VACUUM for an overflow page is
+# intact when a concurrent INSERT changes the primary bucket page.
+#
+# hashbucketcleanup() keeps only a pin on the primary bucket page while it
+# walks the overflow chain, and registers that page (REGBUF_STANDARD |
+# REGBUF_NO_IMAGE | REGBUF_NO_CHANGE) with the XLOG_HASH_DELETE record it
+# writes for each overflow page. With wal_consistency_checking enabled for
+# the hash resource manager, XLogRecordAssemble() includes a full image of
+# every registered block, so it reads the unlocked primary bucket page. If an
+# INSERT adds a tuple to that page after the record's CRC was computed but
+# before the page is copied into the WAL buffers, the record is written with a
+# CRC that does not match its contents. Replay then stops at that record with
+# "incorrect resource manager data checksum".
+#
+# The window is a few microseconds wide, so the test widens it with an
+# injection point in XLogRecordAssemble(), placed right after the CRC is
+# computed. It is attached to the VACUUM session only, and only matches the
+# record in question, identified by "rmgr id/xl_info/number of REGBUF_NO_CHANGE
+# buffers": a hash DELETE with the consistency-check flag (0x92) that registers
+# one such buffer (the unlocked primary bucket page). The point still fires
+# after the bug is fixed, so the test exercises the same interleaving.
+#
+# The assertions state the correct behavior (all WAL is valid and replays), so
+# the test fails while the bug exists.
+
+use strict;
+use warnings FATAL => 'all';
+
+use IPC::Run;
+use PostgreSQL::Test::Cluster;
+use PostgreSQL::Test::Utils;
+use Test::More;
+
+if ($ENV{enable_injection_points} ne 'yes')
+{
+ plan skip_all => 'Injection points not supported by this build';
+}
+
+my $node = PostgreSQL::Test::Cluster->new('primary');
+$node->init;
+$node->append_conf(
+ 'postgresql.conf', qq{
+wal_consistency_checking = 'hash'
+autovacuum = off
+fsync = off
+checkpoint_timeout = 1h
+});
+$node->start;
+
+if (!$node->check_extension('injection_points'))
+{
+ plan skip_all => 'Extension injection_points not installed';
+}
+$node->safe_psql('postgres', 'CREATE EXTENSION injection_points');
+
+my $hash_rmid = $node->safe_psql('postgres',
+ q{SELECT rm_id FROM pg_get_wal_resource_managers() WHERE rm_name = 'Hash'});
+
+# All the rows get the same key, so they land in one bucket: 600 entries fill
+# the primary page (about 400 fit) and one overflow page. Deleting them leaves
+# dead entries on both pages for VACUUM to remove.
+#
+# hashbuild() sizes the index from estimate_rel_size() on the heap, which for a
+# table that has never been vacuumed applies a floor of 10 pages and gives a
+# block-size-dependent number of initial buckets. Vacuuming first sets
+# reltuples to 0, so the estimate is believed and the index starts with the
+# minimum of 2 buckets.
+$node->safe_psql(
+ 'postgres', q{
+CREATE TABLE hash_t (k int) WITH (autovacuum_enabled = false);
+VACUUM hash_t;
+CREATE INDEX hash_i ON hash_t USING hash (k);
+INSERT INTO hash_t SELECT 1 FROM generate_series(1, 600);
+DELETE FROM hash_t;
+});
+
+# Premise: metapage, two bucket pages, a bitmap page and one overflow page.
+is( $node->safe_psql(
+ 'postgres',
+ q{SELECT pg_relation_size('hash_i') / current_setting('block_size')::int}
+ ),
+ '5',
+ 'premise: the index has a primary bucket page and one overflow page');
+
+# Start from a checkpoint, so crash recovery replays everything below and
+# pg_waldump has a record boundary to start from.
+$node->safe_psql('postgres', 'CHECKPOINT');
+my $start_lsn = $node->safe_psql('postgres', 'SELECT pg_current_wal_lsn()');
+
+# The VACUUM session. The point is attached to this session only and must be
+# loaded before the critical section in which it runs.
+my $vacuum = $node->background_psql('postgres');
+$vacuum->query_safe(q{SELECT injection_points_set_local()});
+$vacuum->query_safe(
+ qq{SELECT injection_points_attach('xlog-assemble-after-crc', 'wait', '$hash_rmid/92/1')}
+);
+$vacuum->query_safe(q{SELECT injection_points_load('xlog-assemble-after-crc')});
+$vacuum->query_until(
+ qr/starting_vacuum/,
+ q(\echo starting_vacuum
+VACUUM (INDEX_CLEANUP on) hash_t;
+\q
+));
+
+# VACUUM has removed the dead entries from the primary page, released its lock
+# (keeping the pin), and is now logging the removal from the overflow page: the
+# CRC of that record is computed and the unlocked primary page is not yet
+# copied.
+$node->wait_for_event('client backend', 'xlog-assemble-after-crc');
+note('VACUUM is between computing the CRC and copying the record');
+
+# Now there is room in the primary page, so this INSERT changes it.
+$node->safe_psql('postgres', q{INSERT INTO hash_t VALUES (1)});
+
+$node->safe_psql(
+ 'postgres', q{
+SELECT injection_points_wakeup('xlog-assemble-after-crc');
+SELECT injection_points_detach('xlog-assemble-after-crc');
+});
+$vacuum->quit;
+
+my $end_lsn = $node->safe_psql('postgres', 'SELECT pg_current_wal_insert_lsn()');
+$node->poll_query_until('postgres',
+ "SELECT pg_current_wal_flush_lsn() >= '$end_lsn'")
+ or die "timed out waiting for WAL flush";
+
+# Crash, so that start-up has to replay (and CRC-check) the workload.
+$node->stop('immediate');
+
+# 1. Every record in the range must have a valid CRC. pg_waldump verifies it
+# for every record it reads, whatever the --rmgr filter.
+my $stderr;
+my $ok = IPC::Run::run(
+ [
+ 'pg_waldump',
+ '--path' => $node->data_dir . '/pg_wal',
+ '--start' => $start_lsn,
+ '--end' => $end_lsn,
+ '--rmgr' => 'Hash',
+ ],
+ '>' => '/dev/null',
+ '2>' => \$stderr);
+
+ok($ok, 'pg_waldump reads the whole workload without errors');
+unlike($stderr, qr/incorrect resource manager data checksum/,
+ 'no WAL record has a mismatching CRC');
+
+# 2. Crash recovery must replay it without complaint.
+my $log_offset = -s $node->logfile;
+$node->start;
+my $log = slurp_file($node->logfile, $log_offset);
+unlike(
+ $log,
+ qr/incorrect resource manager data checksum|inconsistent page found/,
+ 'crash recovery replays the workload without CRC or consistency errors');
+
+$node->stop;
+done_testing();
--
2.55.0
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2026-10-23 10:48 Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 03:17 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
2026-10-26 13:46 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2026-10-26 23:06 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
2026-10-27 13:54 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-28 14:54 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification vignesh C <vignesh21@gmail.com>
@ 2026-11-02 06:04 ` vignesh C <vignesh21@gmail.com>
0 siblings, 0 replies; 37+ messages in thread
From: vignesh C @ 2026-11-02 06:04 UTC (permalink / raw)
To: Greg Burd <greg@burd.me>; +Cc: pgsql-hackers; michael@paquier.xyz; andres@anarazel.de; pgsql@j-davis.com; thomas.munro@gmail.com; exclusion@gmail.com; amit.kapila16@gmail.com; hlinnaka@iki.fi
On Wed, 28 Oct 2026 at 20:24, vignesh C <vignesh21@gmail.com> wrote:
>
> Few comments:
> 1. The README, the macro comment, the code comment and the commit
> message say such a buffer "never has a full-page image taken". The
> code is include_image = needs_backup, so an image is still taken when
> needs_backup is true. For example, _hash_freeovflpage() registers the
> write buffer with REGBUF_STANDARD | REGBUF_NO_CHANGE, without
> REGBUF_NO_IMAGE, when the primary bucket page is the write page and no
> tuples are moved onto it. After a checkpoint, that record carries an
> ordinary FPI of the page.
> + The REGBUF_NO_CHANGE flag indicates that the buffer is registered without
> + being modified by this record, and possibly without an exclusive content
> + lock (for example, to force a cleanup lock on the block during replay).
> + Such a buffer never has a full-page image taken, not even when WAL
> + consistency checking is enabled: its contents may change concurrently
>
> Is this ok, or should we mention like "no consistency-check image"
I noticed that the patch has been committed. I thought this comment
might have been missed during the discussion, so here is a small
follow-up patch to clarify the behavior and avoid confusion: "This
does not affect full-page images used for torn-page protection."
Regards,
Vignesh
Attachments:
v1-0001-Clarify-full-page-image-behavior-of-REGBUF_NO_CHA.patch (application/octet-stream, 1.4K) download
From 7b1e6302a182aa5cd460724f25d45f939e38a7e9 Mon Sep 17 00:00:00 2001
From: Vignesh C <vignesh21@gmail.com>
Date: Mon, 2 Nov 2026 11:25:02 +0530
Subject: [PATCH v1] Clarify full-page image behavior of REGBUF_NO_CHANGE in
README
27caf4ca5ae stopped forcing a full-page image for REGBUF_NO_CHANGE
buffers during wal_consistency_checking. This skips only the
consistency-check image, not the full-page image used for torn-page
protection.
A full-page image is still taken on the first registration after a
checkpoint, unless REGBUF_NO_IMAGE is also specified.
Clarify this distinction in the README.
---
src/backend/access/transam/README | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/backend/access/transam/README b/src/backend/access/transam/README
index 595afa01fa7..22e3f971a8f 100644
--- a/src/backend/access/transam/README
+++ b/src/backend/access/transam/README
@@ -589,7 +589,8 @@ void XLogRegisterBuffer(uint8 block_id, Buffer buf, uint8 flags);
The REGBUF_NO_CHANGE flag indicates that the buffer is registered without
being modified by this record, and possibly without an exclusive content
lock. wal_consistency_checking does not force a full-page image for such
- a buffer.
+ a buffer. This does not affect full-page images used for torn-page
+ protection.
void XLogRegisterData(const void *data, int len);
--
2.55.0
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2026-10-23 10:48 Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 03:17 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
2026-10-26 13:46 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2026-10-26 23:06 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
@ 2026-10-28 13:29 ` Greg Burd <greg@burd.me>
2026-10-29 02:27 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
2026-10-29 09:31 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Amit Kapila <amit.kapila16@gmail.com>
2 siblings, 2 replies; 37+ messages in thread
From: Greg Burd @ 2026-10-28 13:29 UTC (permalink / raw)
To: pgsql-hackers@lists.postgresql.org; +Cc: michael@paquier.xyz; andres@anarazel.de; pgsql@j-davis.com; thomas.munro@gmail.com; exclusion@gmail.com; amit.kapila16@gmail.com; hlinnaka@iki.fi
Here is step 2, the hash rework. 0002 is the step 3 end state, marked
NOT FOR MERGE, so you can see where this lands.
0001: Don't register pin-only primary bucket pages in hash WAL records
XLOG_HASH_DELETE, XLOG_HASH_MOVE_PAGE_CONTENTS and
XLOG_HASH_SQUEEZE_PAGE register the primary bucket page only so that
redo takes a cleanup lock on it. Redo never reads data for that block.
0001 puts the block number in the record's main data instead (a new
bucket_blkno field), and redo reads the block and calls
LockBufferForCleanup() on it directly, at the same point and in the same
order as today. The page is registered only when the record changes it.
For SQUEEZE_PAGE that also covers the REGBUF_NO_CHANGE registration of
the write page (the case where the primary page is the write page but
nothing moved onto it): block 1 is now registered only when it is
modified. After this, hash registers only buffers it holds exclusively
locked and dirty.
Reading an unregistered block in redo has precedent: nbtree's "pin scan"
did exactly that (XLogReadBufferExtended + LockBufferForCleanup) until
9f83468b353, which removed it because it was no longer needed, not
because it was unsafe ACAICT. The cost is that recovery prefetch no
longer sees the bucket page for these records. The record format
changes, so XLOG_PAGE_MAGIC is bumped; master only.
Why not lock the bucket page on the primary, as Jeff asked in 2024? I
asked for an exhaustive search.
It deadlocks if you take the lock where the buffer is registered. In
_hash_freeovflpage() that point is after the metapage is locked
exclusive. A scan of a bucket that an incomplete split is still
populating holds that bucket's primary page share-locked and waits for
the metapage in _hash_get_oldblock_from_newbucket(). VACUUM holds the
metapage and waits for the primary page. Both are buffer content locks,
so nothing detects the cycle and cancel doesn't break it. I reproduced
it deterministically with an injection point (3 runs out of 3):
pg_cancel_backend() on the VACUUM does nothing, and every insert into
the index queues behind the metapage. Taking the bucket lock before the
metapage is read avoids it, and that placement passed the same test (3
of 3). That variant still costs a full-page image of the bucket page per
checkpoint and holds inserts and scans on the bucket across the
bitmap/metapage work. The approach taken in 0001 has neither cost and
takes no new lock on the primary.
I read the code and that analysis seems on target to me.
0002 [NOT FOR MERGE]: Remove REGBUF_NO_CHANGE
With 0001 there are no users left, so XLogRegisterBuffer() asserts
unconditionally that every buffer is locked and dirty. On a tree with
the step 1 patch, step 3 would also restore the
Assert(XLogRecHasBlockImage()) in verifyBackupPageConsistency() and drop
the XLogRecordAssemble() special case. On master neither exists yet.
Testing (16-vCPU Debian, cassert builds):
A = master, B = master + step 1, C = master + 0001, D = C + 0002
- CRC reproduction: primary + streaming standby,
wal_consistency_checking = 'hash', 8 sessions inserting and deleting
on a single-bucket index, aggressive autovacuum.
A: the standby stopped on "incorrect resource manager data checksum"
in all runs, as expected (control case).
B, C, D: the standby caught up with no errors, 3 of 3 each.
C and D don't have step 1, and D has neither step 1 nor the
REGBUF_NO_CHANGE escape in XLogRegisterBuffer(), with the replay
assert in verifyBackupPageConsistency() still in place.
So 0001 removes the need for the flag; it doesn't rely on step 1 to
hide the problem.
- Replay correctness: a separate run per build, with and without
wal_consistency_checking, mixing insert/rollback churn, vacuum,
rewrites of a stable row set, and four hot standby readers counting
that set through the index. Each run produced thousands of
DELETE/MOVE/SQUEEZE records with the bucket page not modified.
C and D passed both ways: no bad reads, matching counts on primary and
standby, and matching live-item counts on every bucket and overflow
page.
- Cleanup lock on the standby: a cursor on the standby is parked inside
the bucket's overflow chain, then the primary vacuums so that the
records are 9 DELETE, 4 MOVE_PAGE_CONTENTS and 4 SQUEEZE_PAGE, all
with is_primary F.
On A, C and D, replay waits on BufferCleanup until the cursor
finishes, and the cursor sees all 2250 rows.
As a control, a build of C with the cleanup lock swapped for a plain
exclusive lock lets replay run under the scan, and the cursor only
sees 1686.
- meson test regress, isolation, pg_waldump and the hash module, plus
recovery/027_stream_regress with
PG_TEST_EXTRA=wal_consistency_checking: all pass on C and D.
Of note for reviewers because this does break WAL convention, so it
deserves a bit more scrutiny.
With 0001, redo reads a block that the record does not register. It
takes the relation from a block that is always registered (block 1 for
DELETE and MOVE_PAGE_CONTENTS, block 2 for SQUEEZE_PAGE). It reads the
page with RBM_NORMAL, so a missing page goes through the same
invalid-page tracking as when the page was registered. The page isn't
modified, so it needs no full-page image and no LSN update. Two
consumers of block references stop seeing it. Recovery prefetch is one,
so redo may do one synchronous read of the bucket page per record when
the page isn't already in shared buffers. The other is tools that
collect changed blocks from WAL, such as pg_rewind and the WAL
summarizer. They used to count the bucket page as changed for these
records even though it never was, so dropping it is a fix, not a loss.
The supporting AI-generated scripts are small, attached as
scripts.tgz.nocfbot.
This fix is referenced by another thread working on hash performance
issues as required [0].
best.
-greg
[0] https://postgr.es/m/auHfGQ-MN1Oij_dc@floki
Attachments: download all (3 files, .tar.gz)
v1-0002-NOT-FOR-MERGE-Remove-REGBUF_NO_CHANGE.patch (text/plain, 2.9K) download
From cc5f9211d161725f82545a77477c47d13fa5f5f8 Mon Sep 17 00:00:00 2001
From: Greg Burd <greg@burd.me>
Date: Tue, 27 Oct 2026 13:17:24 -0400
Subject: [PATCH v1 2/2] [NOT FOR MERGE] Remove REGBUF_NO_CHANGE
Preview of the follow-up step, to show the end state after the hash
rework: with hash no longer registering clean or pin-only buffers, there
are no users of REGBUF_NO_CHANGE left, and XLogRegisterBuffer() can
assert unconditionally that every registered buffer is locked and dirty.
On a tree that has the REGBUF_NO_CHANGE full-page-image fix applied,
this step would also restore the Assert(XLogRecHasBlockImage()) in
verifyBackupPageConsistency() and drop the XLogRecordAssemble()
special case; on master neither exists yet, so there is nothing to undo
here.
---
src/backend/access/transam/xloginsert.c | 21 ++++++---------------
src/include/access/xloginsert.h | 1 -
2 files changed, 6 insertions(+), 16 deletions(-)
diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c
index 59b0dfe436d..7212cbb84dc 100644
--- a/src/backend/access/transam/xloginsert.c
+++ b/src/backend/access/transam/xloginsert.c
@@ -256,22 +256,13 @@ XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags)
Assert(begininsert_called);
/*
- * Ordinarily, the buffer should be exclusive-locked (or share-exclusive
- * in case of hint bits) and marked dirty before we get here, otherwise we
- * could end up violating one of the rules in access/transam/README.
- *
- * Some callers intentionally register a clean page and never update that
- * page's LSN; in that case they can pass the flag REGBUF_NO_CHANGE to
- * bypass these checks.
+ * The buffer must be exclusive-locked (or share-exclusive in case of hint
+ * bits) and marked dirty before we get here, otherwise we could end up
+ * violating one of the rules in access/transam/README.
*/
-#ifdef USE_ASSERT_CHECKING
- if (!(flags & REGBUF_NO_CHANGE))
- {
- Assert(BufferIsDirty(buffer));
- Assert(BufferIsLockedByMeInMode(buffer, BUFFER_LOCK_EXCLUSIVE) ||
- BufferIsLockedByMeInMode(buffer, BUFFER_LOCK_SHARE_EXCLUSIVE));
- }
-#endif
+ Assert(BufferIsDirty(buffer));
+ Assert(BufferIsLockedByMeInMode(buffer, BUFFER_LOCK_EXCLUSIVE) ||
+ BufferIsLockedByMeInMode(buffer, BUFFER_LOCK_SHARE_EXCLUSIVE));
if (block_id >= max_registered_block_id)
{
diff --git a/src/include/access/xloginsert.h b/src/include/access/xloginsert.h
index 91dfbd5627f..ddb1a85db59 100644
--- a/src/include/access/xloginsert.h
+++ b/src/include/access/xloginsert.h
@@ -38,7 +38,6 @@
* will be skipped) */
#define REGBUF_KEEP_DATA 0x10 /* include data even if a full-page image
* is taken */
-#define REGBUF_NO_CHANGE 0x20 /* intentionally register clean buffer */
/* prototypes for public functions in xloginsert.c: */
extern void XLogBeginInsert(void);
--
2.50.1
v1-0001-Don-t-register-pin-only-primary-bucket-pages-in-h.patch (text/plain, 15.4K) download
From 879be01737a6c7d5003d1c20ba4d803918c30221 Mon Sep 17 00:00:00 2001
From: Greg Burd <greg@burd.me>
Date: Tue, 27 Oct 2026 13:16:47 -0400
Subject: [PATCH v1 1/2] Don't register pin-only primary bucket pages in hash
WAL records
Replay of XLOG_HASH_DELETE, XLOG_HASH_MOVE_PAGE_CONTENTS and
XLOG_HASH_SQUEEZE_PAGE must take a cleanup lock on the bucket's primary
page, so that a hot standby scan cannot be in progress in the bucket, or
start in it, while tuples are removed or moved. When the primary bucket
page is not itself changed by the record, hashbucketcleanup(),
_hash_squeezebucket() and _hash_freeovflpage() got that lock by
registering the page with REGBUF_NO_CHANGE while holding only a pin on
it. That breaks the rule that a registered buffer is content-locked and
dirtied, and it is why wal_consistency_checking could compute the record
CRC over a page that a concurrent inserter was still changing.
Instead, store the primary bucket page's block number in the main data
of these three records, and have replay read that block and take the
cleanup lock on it directly, in the same order as before. The page is
no longer registered unless the record changes it. For the squeeze
record this also stops registering the write page when it is the
primary bucket page and is not modified.
With this, hash no longer uses REGBUF_NO_CHANGE.
The three record formats change, so bump XLOG_PAGE_MAGIC.
Discussion: https://postgr.es/m/055bb33c-bccc-bc1d-c2f8-8598534448ac@gmail.com
---
src/backend/access/hash/README | 9 ++++
src/backend/access/hash/hash.c | 15 +++----
src/backend/access/hash/hash_xlog.c | 56 ++++++++++++++++-------
src/backend/access/hash/hashovfl.c | 61 ++++++++------------------
src/backend/access/rmgrdesc/hashdesc.c | 9 ++--
src/include/access/hash_xlog.h | 18 ++++++--
src/include/access/xlog_internal.h | 2 +-
7 files changed, 93 insertions(+), 77 deletions(-)
diff --git a/src/backend/access/hash/README b/src/backend/access/hash/README
index fc9031117c9..6d9b14e2d21 100644
--- a/src/backend/access/hash/README
+++ b/src/backend/access/hash/README
@@ -641,6 +641,15 @@ entire bucket. After recovery, the operations will work correctly, but
the index will remain bloated and this can impact performance of read and
insert operations until the next vacuum squeeze the bucket completely.
+Replay of the delete, move-page-contents and squeeze-page records takes a
+cleanup lock on the primary bucket page before touching any other page, so
+that no scan on a hot standby is in progress in the bucket or can start in
+it while tuples are removed or moved; such a scan could otherwise miss
+tuples or return them twice. When the primary bucket page is not one of
+the pages the record changes, the operation holds only a pin on it, so it
+is not registered in the record. The record stores its block number
+instead, and replay locks that block directly.
+
Other Notes
-----------
diff --git a/src/backend/access/hash/hash.c b/src/backend/access/hash/hash.c
index 63846c10840..fc93d78f6bb 100644
--- a/src/backend/access/hash/hash.c
+++ b/src/backend/access/hash/hash.c
@@ -902,6 +902,7 @@ hashbucketcleanup(Relation rel, Bucket cur_bucket, Buffer bucket_buf,
{
xl_hash_delete xlrec;
+ xlrec.bucket_blkno = bucket_blkno;
xlrec.clear_dead_marking = clear_dead_marking;
xlrec.is_primary_bucket_page = (buf == bucket_buf);
@@ -909,17 +910,11 @@ hashbucketcleanup(Relation rel, Bucket cur_bucket, Buffer bucket_buf,
XLogRegisterData(&xlrec, SizeOfHashDelete);
/*
- * bucket buffer was not changed, but still needs to be
- * registered to ensure that we can acquire a cleanup lock on
- * it during replay.
+ * If buf is an overflow page, the primary bucket page is not
+ * changed and we hold only a pin on it, so it is not
+ * registered. Replay takes a cleanup lock on bucket_blkno
+ * instead.
*/
- if (!xlrec.is_primary_bucket_page)
- {
- uint8 flags = REGBUF_STANDARD | REGBUF_NO_IMAGE | REGBUF_NO_CHANGE;
-
- XLogRegisterBuffer(0, bucket_buf, flags);
- }
-
XLogRegisterBuffer(1, buf, REGBUF_STANDARD);
XLogRegisterBufData(1, deletable,
ndeletable * sizeof(OffsetNumber));
diff --git a/src/backend/access/hash/hash_xlog.c b/src/backend/access/hash/hash_xlog.c
index e9a2b9aa9a7..04eb8e17dd4 100644
--- a/src/backend/access/hash/hash_xlog.c
+++ b/src/backend/access/hash/hash_xlog.c
@@ -469,6 +469,33 @@ hash_xlog_split_complete(XLogReaderState *record)
UnlockReleaseBuffer(newbuf);
}
+/*
+ * Take a cleanup lock on the primary bucket page of the bucket that a
+ * squeeze or delete record operates on, when that page is not one of the
+ * pages the record changes and so is not registered in it.
+ *
+ * This serializes replay against scans on a hot standby, which pin the
+ * primary bucket page for their whole duration; see the comments in the
+ * callers. The page is not modified, so nothing is done with it besides
+ * locking it. block_id must be a block of the same index registered in
+ * the record.
+ */
+static Buffer
+hash_xlog_lock_bucket(XLogReaderState *record, uint8 block_id,
+ BlockNumber bucket_blkno)
+{
+ RelFileLocator rlocator;
+ ForkNumber forknum;
+ Buffer buf;
+
+ XLogRecGetBlockTag(record, block_id, &rlocator, &forknum, NULL);
+ buf = XLogReadBufferExtended(rlocator, forknum, bucket_blkno,
+ RBM_NORMAL, InvalidBuffer);
+ if (BufferIsValid(buf))
+ LockBufferForCleanup(buf);
+ return buf;
+}
+
/*
* replay move of page contents for squeeze operation of hash index
*/
@@ -493,11 +520,7 @@ hash_xlog_move_page_contents(XLogReaderState *record)
action = XLogReadBufferForRedoExtended(record, 1, RBM_NORMAL, true, &writebuf);
else
{
- /*
- * we don't care for return value as the purpose of reading bucketbuf
- * is to ensure a cleanup lock on primary bucket page.
- */
- (void) XLogReadBufferForRedoExtended(record, 0, RBM_NORMAL, true, &bucketbuf);
+ bucketbuf = hash_xlog_lock_bucket(record, 1, xldata->bucket_blkno);
action = XLogReadBufferForRedo(record, 1, &writebuf);
}
@@ -617,14 +640,19 @@ hash_xlog_squeeze_page(XLogReaderState *record)
* can miss some records or show the same record multiple times.
*/
if (xldata->is_prim_bucket_same_wrt)
- action = XLogReadBufferForRedoExtended(record, 1, RBM_NORMAL, true, &writebuf);
+ {
+ /* block 1 is absent if the primary bucket page is not modified */
+ if (XLogRecHasBlockRef(record, 1))
+ action = XLogReadBufferForRedoExtended(record, 1, RBM_NORMAL, true, &writebuf);
+ else
+ {
+ bucketbuf = hash_xlog_lock_bucket(record, 2, xldata->bucket_blkno);
+ action = BLK_NOTFOUND;
+ }
+ }
else
{
- /*
- * we don't care for return value as the purpose of reading bucketbuf
- * is to ensure a cleanup lock on primary bucket page.
- */
- (void) XLogReadBufferForRedoExtended(record, 0, RBM_NORMAL, true, &bucketbuf);
+ bucketbuf = hash_xlog_lock_bucket(record, 2, xldata->bucket_blkno);
if (xldata->ntups > 0 || xldata->is_prev_bucket_same_wrt)
action = XLogReadBufferForRedo(record, 1, &writebuf);
@@ -851,11 +879,7 @@ hash_xlog_delete(XLogReaderState *record)
action = XLogReadBufferForRedoExtended(record, 1, RBM_NORMAL, true, &deletebuf);
else
{
- /*
- * we don't care for return value as the purpose of reading bucketbuf
- * is to ensure a cleanup lock on primary bucket page.
- */
- (void) XLogReadBufferForRedoExtended(record, 0, RBM_NORMAL, true, &bucketbuf);
+ bucketbuf = hash_xlog_lock_bucket(record, 1, xldata->bucket_blkno);
action = XLogReadBufferForRedo(record, 1, &deletebuf);
}
diff --git a/src/backend/access/hash/hashovfl.c b/src/backend/access/hash/hashovfl.c
index dbc57ef958c..2bc9015c223 100644
--- a/src/backend/access/hash/hashovfl.c
+++ b/src/backend/access/hash/hashovfl.c
@@ -657,6 +657,7 @@ _hash_freeovflpage(Relation rel, Buffer bucketbuf, Buffer ovflbuf,
{
xl_hash_squeeze_page xlrec;
+ xlrec.bucket_blkno = BufferGetBlockNumber(bucketbuf);
xlrec.prevblkno = prevblkno;
xlrec.nextblkno = nextblkno;
xlrec.ntups = nitups;
@@ -667,42 +668,21 @@ _hash_freeovflpage(Relation rel, Buffer bucketbuf, Buffer ovflbuf,
XLogRegisterData(&xlrec, SizeOfHashSqueezePage);
/*
- * bucket buffer was not changed, but still needs to be registered to
- * ensure that we can acquire a cleanup lock on it during replay.
+ * Register only the pages this record changes. The primary bucket
+ * page is registered only if it is the write page and is modified;
+ * otherwise we may hold only a pin on it, and replay takes a cleanup
+ * lock on bucket_blkno instead.
*/
- if (!is_prim_bucket_same_wrt)
- {
- uint8 flags = REGBUF_STANDARD | REGBUF_NO_IMAGE | REGBUF_NO_CHANGE;
-
- XLogRegisterBuffer(0, bucketbuf, flags);
- }
-
- if (nitups > 0)
+ if (mod_wbuf)
{
XLogRegisterBuffer(1, wbuf, REGBUF_STANDARD);
- XLogRegisterBufData(1, itup_offsets,
- nitups * sizeof(OffsetNumber));
- for (int i = 0; i < nitups; i++)
- XLogRegisterBufData(1, itups[i], tups_size[i]);
- }
- else if (is_prim_bucket_same_wrt || is_prev_bucket_same_wrt)
- {
- uint8 wbuf_flags;
-
- /*
- * A write buffer needs to be registered even if no tuples are
- * added to it to ensure that we can acquire a cleanup lock on it
- * if it is the same as primary bucket buffer or update the
- * nextblkno if it is same as the previous bucket buffer.
- */
- Assert(nitups == 0);
-
- wbuf_flags = REGBUF_STANDARD;
- if (!is_prev_bucket_same_wrt)
- wbuf_flags |= REGBUF_NO_CHANGE;
- else
- Assert(mod_wbuf);
- XLogRegisterBuffer(1, wbuf, wbuf_flags);
+ if (nitups > 0)
+ {
+ XLogRegisterBufData(1, itup_offsets,
+ nitups * sizeof(OffsetNumber));
+ for (int i = 0; i < nitups; i++)
+ XLogRegisterBufData(1, itups[i], tups_size[i]);
+ }
}
XLogRegisterBuffer(2, ovflbuf, REGBUF_STANDARD);
@@ -991,6 +971,7 @@ readpage:
{
xl_hash_move_page_contents xlrec;
+ xlrec.bucket_blkno = bucket_blkno;
xlrec.ntups = nitups;
xlrec.is_prim_bucket_same_wrt = (wbuf == bucket_buf);
@@ -998,17 +979,11 @@ readpage:
XLogRegisterData(&xlrec, SizeOfHashMovePageContents);
/*
- * bucket buffer was not changed, but still needs to
- * be registered to ensure that we can acquire a
- * cleanup lock on it during replay.
+ * If wbuf is an overflow page, the primary bucket
+ * page is not changed and we hold only a pin on it,
+ * so it is not registered. Replay takes a cleanup
+ * lock on bucket_blkno instead.
*/
- if (!xlrec.is_prim_bucket_same_wrt)
- {
- int flags = REGBUF_STANDARD | REGBUF_NO_IMAGE | REGBUF_NO_CHANGE;
-
- XLogRegisterBuffer(0, bucket_buf, flags);
- }
-
XLogRegisterBuffer(1, wbuf, REGBUF_STANDARD);
XLogRegisterBufData(1, itup_offsets,
nitups * sizeof(OffsetNumber));
diff --git a/src/backend/access/rmgrdesc/hashdesc.c b/src/backend/access/rmgrdesc/hashdesc.c
index 593013afe9c..6988b6a82c3 100644
--- a/src/backend/access/rmgrdesc/hashdesc.c
+++ b/src/backend/access/rmgrdesc/hashdesc.c
@@ -80,7 +80,8 @@ hash_desc(StringInfo buf, XLogReaderState *record)
{
xl_hash_move_page_contents *xlrec = (xl_hash_move_page_contents *) rec;
- appendStringInfo(buf, "ntups %d, is_primary %c",
+ appendStringInfo(buf, "bucket_blkno %u, ntups %d, is_primary %c",
+ xlrec->bucket_blkno,
xlrec->ntups,
xlrec->is_prim_bucket_same_wrt ? 'T' : 'F');
break;
@@ -89,7 +90,8 @@ hash_desc(StringInfo buf, XLogReaderState *record)
{
xl_hash_squeeze_page *xlrec = (xl_hash_squeeze_page *) rec;
- appendStringInfo(buf, "prevblkno %u, nextblkno %u, ntups %d, is_primary %c, is_previous %c",
+ appendStringInfo(buf, "bucket_blkno %u, prevblkno %u, nextblkno %u, ntups %d, is_primary %c, is_previous %c",
+ xlrec->bucket_blkno,
xlrec->prevblkno,
xlrec->nextblkno,
xlrec->ntups,
@@ -101,7 +103,8 @@ hash_desc(StringInfo buf, XLogReaderState *record)
{
xl_hash_delete *xlrec = (xl_hash_delete *) rec;
- appendStringInfo(buf, "clear_dead_marking %c, is_primary %c",
+ appendStringInfo(buf, "bucket_blkno %u, clear_dead_marking %c, is_primary %c",
+ xlrec->bucket_blkno,
xlrec->clear_dead_marking ? 'T' : 'F',
xlrec->is_primary_bucket_page ? 'T' : 'F');
break;
diff --git a/src/include/access/hash_xlog.h b/src/include/access/hash_xlog.h
index 149aed69dc5..9d762ff70d3 100644
--- a/src/include/access/hash_xlog.h
+++ b/src/include/access/hash_xlog.h
@@ -129,12 +129,15 @@ typedef struct xl_hash_split_complete
*
* This data record is used for XLOG_HASH_MOVE_PAGE_CONTENTS
*
- * Backup Blk 0: primary bucket page
* Backup Blk 1: page containing moved tuples
* Backup Blk 2: page from which tuples will be removed
+ *
+ * The primary bucket page is not registered; replay takes a cleanup lock on
+ * bucket_blkno instead.
*/
typedef struct xl_hash_move_page_contents
{
+ BlockNumber bucket_blkno; /* primary bucket page */
uint16 ntups;
bool is_prim_bucket_same_wrt; /* true if the page to which
* tuples are moved is same as
@@ -149,16 +152,20 @@ typedef struct xl_hash_move_page_contents
*
* This data record is used for XLOG_HASH_SQUEEZE_PAGE
*
- * Backup Blk 0: primary bucket page
- * Backup Blk 1: page containing tuples moved from freed overflow page
+ * Backup Blk 1: page containing tuples moved from freed overflow page, if
+ * it is modified
* Backup Blk 2: freed overflow page
* Backup Blk 3: page previous to the freed overflow page
* Backup Blk 4: page next to the freed overflow page
* Backup Blk 5: bitmap page containing info of freed overflow page
* Backup Blk 6: meta page
+ *
+ * The primary bucket page is registered only as block 1, when it is the
+ * modified write page; otherwise replay takes a cleanup lock on bucket_blkno.
*/
typedef struct xl_hash_squeeze_page
{
+ BlockNumber bucket_blkno; /* primary bucket page */
BlockNumber prevblkno;
BlockNumber nextblkno;
uint16 ntups;
@@ -179,11 +186,14 @@ typedef struct xl_hash_squeeze_page
*
* This data record is used for XLOG_HASH_DELETE
*
- * Backup Blk 0: primary bucket page
* Backup Blk 1: page from which tuples are deleted
+ *
+ * If block 1 is not the primary bucket page, replay takes a cleanup lock on
+ * bucket_blkno, which is not registered.
*/
typedef struct xl_hash_delete
{
+ BlockNumber bucket_blkno; /* primary bucket page */
bool clear_dead_marking; /* true if this operation clears
* LH_PAGE_HAS_DEAD_TUPLES flag */
bool is_primary_bucket_page; /* true if the operation is for
diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h
index bf609c3c703..ed8f488dda5 100644
--- a/src/include/access/xlog_internal.h
+++ b/src/include/access/xlog_internal.h
@@ -32,7 +32,7 @@
/*
* Each page of XLOG file has a header like this:
*/
-#define XLOG_PAGE_MAGIC 0xD122 /* can be used as WAL version indicator */
+#define XLOG_PAGE_MAGIC 0xD123 /* can be used as WAL version indicator */
typedef struct XLogPageHeaderData
{
--
2.50.1
scripts.tgz.nocfbot (application/octet-stream, 23.2K) download
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2026-10-23 10:48 Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 03:17 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
2026-10-26 13:46 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2026-10-26 23:06 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
2026-10-28 13:29 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
@ 2026-10-29 02:27 ` Michael Paquier <michael@paquier.xyz>
1 sibling, 0 replies; 37+ messages in thread
From: Michael Paquier @ 2026-10-29 02:27 UTC (permalink / raw)
To: Greg Burd <greg@burd.me>; +Cc: pgsql-hackers@lists.postgresql.org; andres@anarazel.de; pgsql@j-davis.com; thomas.munro@gmail.com; exclusion@gmail.com; amit.kapila16@gmail.com; hlinnaka@iki.fi
On Wed, Oct 28, 2026 at 01:29:39PM +0000, Greg Burd wrote:
> - CRC reproduction: primary + streaming standby,
> wal_consistency_checking = 'hash', 8 sessions inserting and deleting
> on a single-bucket index, aggressive autovacuum.
>
> A: the standby stopped on "incorrect resource manager data checksum"
> in all runs, as expected (control case).
>
> B, C, D: the standby caught up with no errors, 3 of 3 each.
That sounds encouraging, as a start.
Could you start a new thread about all that, with all the authors of
this original code in CC at least? Hiding such a large refactoring on
a thread for the CRC failure would not help in terms of attracting
the attention this requires in terms of reviews.
You could also add me in CC if you wish. As far as I recall, we
rely on the registered buffer at replay to lift a bit the lock
restrictions for concurrency purposes, but that's pretty specialized
in itself.
Thanks,
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2026-10-23 10:48 Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 03:17 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
2026-10-26 13:46 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2026-10-26 23:06 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
2026-10-28 13:29 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
@ 2026-10-29 09:31 ` Amit Kapila <amit.kapila16@gmail.com>
1 sibling, 0 replies; 37+ messages in thread
From: Amit Kapila @ 2026-10-29 09:31 UTC (permalink / raw)
To: Greg Burd <greg@burd.me>; +Cc: pgsql-hackers@lists.postgresql.org; michael@paquier.xyz; andres@anarazel.de; pgsql@j-davis.com; thomas.munro@gmail.com; exclusion@gmail.com; hlinnaka@iki.fi
On Wed, Oct 28, 2026 at 6:59 PM Greg Burd <greg@burd.me> wrote:
>
> Here is step 2, the hash rework. 0002 is the step 3 end state, marked
> NOT FOR MERGE, so you can see where this lands.
>
> 0001: Don't register pin-only primary bucket pages in hash WAL records
>
> XLOG_HASH_DELETE, XLOG_HASH_MOVE_PAGE_CONTENTS and
> XLOG_HASH_SQUEEZE_PAGE register the primary bucket page only so that
> redo takes a cleanup lock on it. Redo never reads data for that block.
>
> 0001 puts the block number in the record's main data instead (a new
> bucket_blkno field), and redo reads the block and calls
> LockBufferForCleanup() on it directly, at the same point and in the same
> order as today. The page is registered only when the record changes it.
>
> For SQUEEZE_PAGE that also covers the REGBUF_NO_CHANGE registration of
> the write page (the case where the primary page is the write page but
> nothing moved onto it): block 1 is now registered only when it is
> modified. After this, hash registers only buffers it holds exclusively
> locked and dirty.
>
> Reading an unregistered block in redo has precedent: nbtree's "pin scan"
> did exactly that (XLogReadBufferExtended + LockBufferForCleanup) until
> 9f83468b353, which removed it because it was no longer needed, not
> because it was unsafe ACAICT. The cost is that recovery prefetch no
> longer sees the bucket page for these records. The record format
> changes, so XLOG_PAGE_MAGIC is bumped; master only.
>
This approach looks reasonable to me.
*
@@ -902,6 +902,7 @@ hashbucketcleanup(Relation rel, Bucket cur_bucket,
Buffer bucket_buf,
{
xl_hash_delete xlrec;
+ xlrec.bucket_blkno = bucket_blkno;
xlrec.clear_dead_marking = clear_dead_marking;
Though harmless, we don't need this for primary bucket pages, so one
idea could be to use XLogRegisterData to register this block number
for overflow pages only. This would save four bytes for the cases
where we don't perform the cleanup operations on overflow pages, the
same would be true for other cases.
--
With Regards,
Amit Kapila.
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2026-10-23 10:48 Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 03:17 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
2026-10-26 13:46 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2026-10-26 23:06 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
@ 2026-10-28 15:57 ` Andres Freund <andres@anarazel.de>
2026-10-29 02:19 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
2 siblings, 1 reply; 37+ messages in thread
From: Andres Freund @ 2026-10-28 15:57 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; +Cc: Greg Burd <greg@burd.me>; pgsql-hackers; pgsql@j-davis.com; thomas.munro@gmail.com; exclusion@gmail.com; amit.kapila16@gmail.com; hlinnaka@iki.fi
On 2026-10-27 08:06:48 +0900, Michael Paquier wrote:
> On Mon, Oct 26, 2026 at 09:46:18AM -0400, Andres Freund wrote:
> > I frankly think it's pretty much unacceptable for a niche index like hash to
> > violate the rules like that. If it were btree, it'd perhaps be worthwhile to
> > add generic infrastructure for this, but here it doesn't seem like the juice
> > is worth the squeeze.
>
> I'm definitely not convinced that hash is a sufficient argument for
> having more infrastructure. What this is telling us here is the
> contrary: we should have less infrastructure. So I'd love to be able
> to put REGBUF_NO_CHANGE in the garbage bin and have an assert in the
> replay code instead of silently ignoring a case.
Agreed.
> > I'm not really convinced by that argument. It's probably the best answer in
> > the back branches, but I think we shouldn't do this in master.
>
> I'm not sure that I can side with your argument here. Doing nothing
> on master means that we're still open to the CRC problem until we
> decide to fix hash, so it still looks like a problem that needs to be
> tackled in three steps:
> - Avoid the CRC problem down to v17, including HEAD.
> - Address hash to avoid the rule breakage.
> - Lift the check in replay for wal_consistency_checking (re-add the
> assert) and push REGBUF_NO_CHANGE into orbit.
Fair enough. I guess I'd hoped that one of the folks involved in adding the
hash index WAL logging would chime in and fix this properly.
> There is nothing more permanent than a temporary fix, as some say,
> but I'd like to trust in something happening for hash.
I guess I don't have that trust in this case. This IIRC isn't the first
complaint about the odd locking stuff that hash has.
Ceterum censeo index access/hash esse delendum.
Greetings,
Andres Freund
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2026-10-23 10:48 Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 03:17 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
2026-10-26 13:46 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
2026-10-26 23:06 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
2026-10-28 15:57 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Andres Freund <andres@anarazel.de>
@ 2026-10-29 02:19 ` Michael Paquier <michael@paquier.xyz>
0 siblings, 0 replies; 37+ messages in thread
From: Michael Paquier @ 2026-10-29 02:19 UTC (permalink / raw)
To: Andres Freund <andres@anarazel.de>; +Cc: Greg Burd <greg@burd.me>; pgsql-hackers; pgsql@j-davis.com; thomas.munro@gmail.com; exclusion@gmail.com; amit.kapila16@gmail.com; hlinnaka@iki.fi
On Wed, Oct 28, 2026 at 11:57:53AM -0400, Andres Freund wrote:
> Fair enough. I guess I'd hoped that one of the folks involved in adding the
> hash index WAL logging would chime in and fix this properly.
If input does not show up, I see nothing to do here except somebody
else popping up to take responsibility for the change. Actually, I
may not mind, this stuff is annoying..
Applied the workaround down to v17 for now.
> Ceterum censeo index access/hash esse delendum.
I doubt we would be able to do that, if ever.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2026-10-23 10:48 Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 03:17 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
@ 2026-11-02 08:51 ` vignesh C <vignesh21@gmail.com>
2026-11-02 11:01 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
1 sibling, 1 reply; 37+ messages in thread
From: vignesh C @ 2026-11-02 08:51 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; +Cc: Greg Burd <greg@burd.me>; pgsql-hackers; pgsql@j-davis.com; thomas.munro@gmail.com; exclusion@gmail.com; andres@anarazel.de; amit.kapila16@gmail.com; hlinnaka@iki.fi
On Mon, 26 Oct 2026 at 08:48, Michael Paquier <michael@paquier.xyz> wrote:
>
> Honestly, I am not convinced that it is worth bothering with the
> v14~16 branches: REGBUF_NO_CHANGE does not exist there, and we would
> need to identify a way to identify pin-only buffers, probably with an
> exclusive lock check when a record is assembled, or something like
> that. I really cannot get excited by that just for the sake of making
> wal_consistency_checking able to work better for hash records there.
> So let's leave it at v17~ where the regbuf flag exists.
While looking at the back-branch behavior of 27caf4ca5ae, I checked
its impact on mixed minor-version replication. Since this changes what
the primary writes in back branches (17–19), I wanted to check whether
it needs a release note. I tested REL_18 with and without the commit,
using both streaming replication and crash recovery. I found one case
that fails: a primary with the commit and wal_consistency_checking
enabled for hash, streaming to a standby without the commit. The new
primary no longer writes a consistency image for the registered
NO_CHANGE block. However, the older standby expects an image for every
registered block in a flagged record. It stops at the first such
record with an assertion failure in an assert build, or a FATAL error
otherwise. The standby works normally after it is updated. Without
wal_consistency_checking, the WAL remains unchanged. Disabling the
setting on the standby does not help because the flag is part of the
WAL record. This affects only users who enable
wal_consistency_checking in production, but it can cause a standby to
stop until it is updated.
I was wondering whether we should mention this in the release notes,
advising users to update standbys before primaries or disable
wal_consistency_checking on the primary until all nodes are updated.
Regards,
Vignesh
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2026-10-23 10:48 Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 03:17 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
2026-11-02 08:51 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification vignesh C <vignesh21@gmail.com>
@ 2026-11-02 11:01 ` Michael Paquier <michael@paquier.xyz>
2026-11-02 13:25 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification vignesh C <vignesh21@gmail.com>
0 siblings, 1 reply; 37+ messages in thread
From: Michael Paquier @ 2026-11-02 11:01 UTC (permalink / raw)
To: vignesh C <vignesh21@gmail.com>; +Cc: Greg Burd <greg@burd.me>; pgsql-hackers; pgsql@j-davis.com; thomas.munro@gmail.com; exclusion@gmail.com; andres@anarazel.de; amit.kapila16@gmail.com; hlinnaka@iki.fi
On Mon, Nov 02, 2026 at 02:21:58PM +0530, vignesh C wrote:
> I was wondering whether we should mention this in the release notes,
> advising users to update standbys before primaries or disable
> wal_consistency_checking on the primary until all nodes are updated.
wal_consistency_checking is a developer option. I doubt that this is
worth mentioning in the release notes: nobody should use it in
production environments.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 37+ messages in thread
* Re: WAL record CRC calculated incorrectly because of underlying buffer modification
2026-10-23 10:48 Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 03:17 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
2026-11-02 08:51 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification vignesh C <vignesh21@gmail.com>
2026-11-02 11:01 ` Re: WAL record CRC calculated incorrectly because of underlying buffer modification Michael Paquier <michael@paquier.xyz>
@ 2026-11-02 13:25 ` vignesh C <vignesh21@gmail.com>
0 siblings, 0 replies; 37+ messages in thread
From: vignesh C @ 2026-11-02 13:25 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; +Cc: Greg Burd <greg@burd.me>; pgsql-hackers; pgsql@j-davis.com; thomas.munro@gmail.com; exclusion@gmail.com; andres@anarazel.de; amit.kapila16@gmail.com; hlinnaka@iki.fi
On Mon, 2 Nov 2026 at 16:31, Michael Paquier <michael@paquier.xyz> wrote:
>
> On Mon, Nov 02, 2026 at 02:21:58PM +0530, vignesh C wrote:
> > I was wondering whether we should mention this in the release notes,
> > advising users to update standbys before primaries or disable
> > wal_consistency_checking on the primary until all nodes are updated.
>
> wal_consistency_checking is a developer option. I doubt that this is
> worth mentioning in the release notes: nobody should use it in
> production environments.
Thanks, that makes sense. Then nothing else is required for this.
Regards,
Vignesh
^ permalink raw reply [nested|flat] 37+ messages in thread
end of thread, other threads:[~2026-11-02 13:25 UTC | newest]
Thread overview: 37+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-05-10 13:00 WAL record CRC calculated incorrectly because of underlying buffer modification Alexander Lakhin <exclusion@gmail.com>
2024-05-10 15:57 ` Andres Freund <andres@anarazel.de>
2024-05-11 03:26 ` Thomas Munro <thomas.munro@gmail.com>
2024-05-11 04:00 ` Alexander Lakhin <exclusion@gmail.com>
2024-05-11 04:25 ` Thomas Munro <thomas.munro@gmail.com>
2024-05-11 05:00 ` Alexander Lakhin <exclusion@gmail.com>
2024-05-12 23:15 ` Thomas Munro <thomas.munro@gmail.com>
2024-05-16 22:54 ` Jeff Davis <pgsql@j-davis.com>
2024-05-17 01:12 ` Michael Paquier <michael@paquier.xyz>
2024-05-17 14:56 ` Jeff Davis <pgsql@j-davis.com>
2024-05-17 15:38 ` Robert Haas <robertmhaas@gmail.com>
2026-10-23 10:48 Re: WAL record CRC calculated incorrectly because of underlying buffer modification Greg Burd <greg@burd.me>
2026-10-26 03:17 ` Michael Paquier <michael@paquier.xyz>
2026-10-26 13:46 ` Andres Freund <andres@anarazel.de>
2026-10-26 14:33 ` Greg Burd <greg@burd.me>
2026-10-26 15:15 ` Andres Freund <andres@anarazel.de>
2026-10-26 15:38 ` Greg Burd <greg@burd.me>
2026-10-26 18:08 ` shihao zhong <zhong950419@gmail.com>
2026-10-27 13:04 ` Greg Burd <greg@burd.me>
2026-10-27 14:04 ` shihao zhong <zhong950419@gmail.com>
2026-10-27 14:32 ` Greg Burd <greg@burd.me>
2026-10-29 20:33 ` Jeff Davis <pgsql@j-davis.com>
2026-10-29 20:49 ` Jeff Davis <pgsql@j-davis.com>
2026-10-30 02:51 ` shihao zhong <zhong950419@gmail.com>
2026-10-30 19:13 ` Jeff Davis <pgsql@j-davis.com>
2026-10-26 23:06 ` Michael Paquier <michael@paquier.xyz>
2026-10-27 13:54 ` Greg Burd <greg@burd.me>
2026-10-28 14:54 ` vignesh C <vignesh21@gmail.com>
2026-11-02 06:04 ` vignesh C <vignesh21@gmail.com>
2026-10-28 13:29 ` Greg Burd <greg@burd.me>
2026-10-29 02:27 ` Michael Paquier <michael@paquier.xyz>
2026-10-29 09:31 ` Amit Kapila <amit.kapila16@gmail.com>
2026-10-28 15:57 ` Andres Freund <andres@anarazel.de>
2026-10-29 02:19 ` Michael Paquier <michael@paquier.xyz>
2026-11-02 08:51 ` vignesh C <vignesh21@gmail.com>
2026-11-02 11:01 ` Michael Paquier <michael@paquier.xyz>
2026-11-02 13:25 ` vignesh C <vignesh21@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox