model-writtenrun 260 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Melanie Plageman opened the thread after she and Andres Freund noticed that heap operations cleared visibility-map bits without registering the VM buffer in WAL, preventing full-page images for those changes #1.
- Andres reproduced an incremental backup restoring an outdated visibility map and observed that verify_heapam() missed the inconsistency, establishing both a corruption bug and a diagnostic gap #5.
- Robert Haas explained the historical reliance on idempotent bit clearing and favored unconditional VM-buffer registration rather than behavior conditional on checksums or WAL settings #8.
- The investigation also exposed questions about VM truncation and replay validation: Andres proposed stronger checks on recovery reads and registered blocks, while Robert emphasized keeping related changes, locks, and WAL records within correctly bounded operations #11 #13 #16.
- Melanie's first series built on Andres's work, supplied separate master and PostgreSQL 18 implementations, added incremental-backup tests, and proposed three further validation patches; backpatching was limited to PostgreSQL 17 and newer, where incremental backups made the problem directly consequential #17.
- Robert objected to losing useful pg_combinebackup debug output, and discussion with Andres settled on retaining it separately; Melanie incorporated temporary-file logging in the next submission #18 #19 #20 #22.
- Andres's detailed review found a possible deadlock when UPDATE acquired two VM locks in opposite orders, requested clearer block-reference identifiers, and suggested test consolidation and stronger amcheck checks; Melanie incorporated those changes and combined pg_surgery's heap and VM logging into one record #21 #22.
- After a gap, Melanie returned with an invasive PostgreSQL 18 refactor that acquired VM locks before critical sections and registered buffers only when their bits actually changed, addressing cases where PD_ALL_VISIBLE remained set while VM bits were already clear #24.
- A related discussion with Tomas Vondra established that stale cleared_all_frozen state could survive an update-chain iteration: it was an efficiency issue before the patch but could cause invalid buffer registration under the proposed implementation #23 #25.
- Andrey Borodin verified that the new test detected the original bug and that patched and unpatched PostgreSQL 18 could replay each other's WAL, then found the missing pg_visibility test dependency #27 #28.
- Robert's review prompted clearer naming and comments, guarded LSN updates, and performance investigation; Melanie retained block-reference macros for readability and reported contention-related degradation only in her asynchronous-commit stress case #29 #30.
- CI then exposed incorrect labeling when UPDATE cleared only the old tuple's bits on a shared VM page; Melanie fixed it, supplied an optional alternative organization of heap_update(), and finished the branch-specific implementations #32.
- Following Robert's Perl-infrastructure review, Melanie separated the pg_combinebackup verbosity patch for a future master-focused thread so it would no longer hold up the correctness fixes #33 #34.
- The July landing included the RelFileLocator API refactor from the earlier master series as 2340fb8f02 and the final incremental-backup test from #32 as 5174d157a0, with the latter differing only by a comment typo correction; Melanie announced the main branch landings in #36.
- Melanie resubmitted the three remaining validation patches, but considered delaying removal of PD_ALL_VISIBLE masking until corruption repair was WAL-logged, because otherwise consistency checks could reject repaired pages #36.
- Fujii Masao identified the loss of visibilitymap_clear()'s runtime wrong-buffer check, and Melanie restored it in 4dbc54506c; Andres subsequently questioned the need for a runtime error but did not seek another reversal #37 #38 #39 #40.
- Tom Lane reported Coverity's complaint about an unchecked visibilitymap_clear() result, and Melanie explained that corruption repair did not emit WAL and therefore did not need the result; a37e574545 added the requested comment and explicit void cast #41 #42 #43.
- In September, Melanie reported that CREATE DATABASE STRATEGY WAL_LOG and failover could leave the primary and standby with different VM bits, making skipped no-op clears corrupt standby visibility; she initially proposed registering unchanged VM buffers, while leaving tuple locking unresolved because of its performance cost #44.
- Melanie then replaced that approach with replay-side clearing of unregistered VM bits, avoiding a general requirement to WAL-log pages merely because another node might differ; the new patch also warned about divergence and stamped the repaired page's LSN #46 #47.
- Andrey identified that replay could encounter a VM page already ahead of the record, making the warning misleading and moving its LSN backward, and questioned whether the proposed read mode could tolerate torn pages #48.
- The earlier amcheck validation patch landed as 5d84c76021, selecting the first patch of #36 with comment polishing; Melanie cited it as a foundation for testing VM corruption in #49.
- Melanie revised the repair series to remove warnings and LSN stamping, add branch-specific fallback implementations, propose ZERO_ON_ERROR reads, and repair stale all-frozen bits; broader warning and WAL-logging changes were reserved for a separate master-focused effort #49.
- Andrey reproduced a remaining UPDATE failure because the revised fallback covered the shared helper but omitted heap_xlog_update(), and pointed to related PageInit work in another thread #50.
- Melanie later withdrew the proposed ZERO_ON_ERROR change after reasoning that registered VM changes retained full-page-image protection, while continuing to support the divergent-VM fallback and stale-all-frozen repair; tuple locking and broader hardening remained open #51.
- The thread ends with Amit Kapila identifying outdated WAL-logging, lock-order, and LSN comments in visibilitymap.c; no completed landing of the September repair series or the remaining replay-validation and masking proposals is demonstrated in the supplied thread #52.