model-writtenrun 8443 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Matthias van de Meent opened the thread after Konstantin Knizhnik identified that WAL-logged database copies could discard meaningful data from nonstandard pages, proposing that all copied pages disable hole removal #1.
- Tom Lane and Robert Haas objected to the increased WAL volume, while Matthias emphasized correctness and the lack of reliable page-layout information; Michael Paquier later suggested passing layout knowledge down from callers #2 #3 #4 #6.
- After a long gap, Rogers Wang revived the issue with a PostgreSQL 19 assertion failure caused by divergent visibility maps after switchover, supplying a fork-specific VM/FSM fix and recovery tests that he reported failed without the fix and passed with it #8.
- Michael Paquier raised the PostgreSQL 19 release concern, and Melanie Plageman separated the redo bug from the database-copy bug: visibilitymap_set() can legitimately leave a buffer unchanged, so redo must not assume it dirtied the page #9 #10.
- Melanie submitted a separate patch restoring visibilitymap_set()'s return value and setting the VM page LSN only when bits change; it landed unchanged apart from rebasing as 3245795e13, with a PostgreSQL 19 backport, and she marked the release item resolved #12 #13.
- Melanie subsequently identified a more serious consequence of the remaining database-copy bug: after promotion, tuple locking could leave stale all-frozen bits on the former primary and cause corruption, making prevention necessary; she also supplied a reproducer #14 #15.
- Robert reconsidered his earlier objection because old GIN indexes also use nonstandard pages, while Melanie endorsed backpatching the VM/FSM fix and explored an off-list suggestion from Andres to identify ordinary heap pages through catalog information #16 #17.
- Following further off-list discussion, Melanie replaced catalog or fork classification with a rule that omits an apparent hole only when its bytes are already zero, adding shared bounds validation and a simpler primary/standby page-comparison test #18.
- Surya Poondla built and tested the new patch, supported its correctness, and demonstrated that checksum differences could make the test fail with larger shared buffers; he also measured substantial extra WAL for updated templates and identified older-branch compatibility work #19.
- Robert explained that heap pruning leaves nonzero garbage in otherwise disposable free space and proposed preserving unconditional hole removal for known-standard heap and B-tree main forks, with the WAL-volume tradeoff documented for other access methods #20.
- Melanie adopted that hybrid policy in the revised database-copy fix, passing layout knowledge from the catalog scan while retaining zero-byte checks for unknown layouts; she also added a separate, master-only patch applying the policy to RelationCopyStorage() to reduce WAL during relation moves #21.
- The revised test compares per-block pg_visibility_map() results instead of raw pages, avoiding checksum differences; Melanie omitted FSM comparisons because inaccurate FSM contents do not threaten correctness and defended shared bounds validation as protection against code drift #21 #22.
- Surya reported that both patches built cleanly, the recovery test passed with the fix and failed without it, and the updated-template WAL regression fell from 117 MB to 80 MB against a 79 MB baseline; the separate optimization also reduced heap and B-tree tablespace-move WAL #23.
- Zhijie Hou found that the new test accidentally bypassed the existing regression scenario by loading pg_class pages too early; Melanie moved the VM test after the original test and incorporated Surya's all-frozen assertion in the revised series #24 #25 #26.
- Melanie identified the need to preserve the public CreateAndCopyRelationData() interface in backports, and Surya recommended a conservative false argument for its compatibility wrapper while also identifying a redundant include in the optimization patch #25 #27.
- Zhijie found that the test's small shared_buffers setting could still erase the original regression coverage and requested 16MB; independently, he supplied a draft consistency-checking fix because heap_mask() was zeroing entire VM bitmaps before comparison #28.
- Surya tested Zhijie's consistency-checking draft and reproduced a standby failure that disappeared with the database-copy fix; he also suggested passing fork information into masking callbacks on master and raised the separate issue of VM repairs that bypass WAL #30.
- After discussing stronger protection for the original regression test, Melanie chose an explanatory comment and increased shared_buffers rather than adding a cache-residency assertion #29 #31 #32.
- Melanie committed the database-copy portion of #25 as db26517e79, with only the additional test configuration and comment, and backpatched it through PostgreSQL 15 #32.
- The remaining master-only optimization was resubmitted with an explicit built-in heap-AM check, a use_wal guard around zero scanning, and a test that moved visibility-map contents survive crash recovery #32.
- Michael Paquier suggested tying buffer tuning to consistency checking, but Melanie clarified that the larger buffer setting preserves the original regression test independently of wal_consistency_checking #33 #34.
- Melanie committed the remaining optimization from #32 as ecb2608535, changing only a code comment and the commit message; both copy-related changes are landed, while visibility-map consistency-checking work continues in a new thread #35.