model-writtenrun 594 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Polina Bungina reported that pg_rewind could delete the only remaining copies of unarchived WAL needed to restart a demoted primary, and proposed tracking segments read between divergence and the last common checkpoint in a separate hash table #1.
- After initially questioning the failure scenario, Kyotaro Horiguchi accepted the problem following Alexander Kukushkin's reproduction and suggested identifying required segments by filename and checkpoint position #7 #9 #10.
- Alexander explained that multiple timeline changes complicate filename-based selection and favored tracking files actually opened during the backward checkpoint search; Kyotaro then proposed recording preservation directly in the existing file map #11 #13 #14.
- Polina implemented the shared-file-map approach, while discussion of preserving or creating archive_status files was deferred because duplicate archiving was considered harmless and handling conflicting status files added complexity #16 #19.
- Polina retained the flag restricting preservation to checkpoint-search reads after explaining that other readers also visit unnecessary segments, and incorporated Kyotaro's preserve_file() helper and undecided-action check #20 #21 #22.
- After a long gap, Atsushi Torikoshi reproduced the problem and verified that the patch allowed the old primary to become a standby, distinguishing the deletion bug from a separate need to restore newer WAL from archive #23 #25.
- Michael Paquier objected to the hidden dependency between the page-read callback and filemap.c, suggested tracking segments in findLastCheckpoint(), preferred copying source WAL when available, and requested a regression test; Alexander took over submissions and moved tracking into the checkpoint-search function #27 #29.
- Although Kyotaro and Atsushi preferred keeping file actions in one place, Alexander restored a separate preservation hash and restricted its use to files missing from the source, retaining normal source copying and adding a TAP test #30 #31 #32.
- Alexander made the test portable to Windows and then incorporated Atsushi's successful testing and cleanup feedback, including qualified helper calls, clearer comments, and removal of a stale declaration #33 #34 #35 #36 #37.
- Sutou Kouhei revived the patch in July 2024 with a rebase, Meson test registration, and formatting changes, and identified an incorrect snprintf() buffer bound; Alexander corrected the bound without adding another buffer #41 #42.
- Alvaro Herrera endorsed the separate hash for maintainability, verified that the test exercised the problematic case, and posted a polished version; he planned backpatches through PostgreSQL 14 but left PostgreSQL 13 unfixed because it lacked prerequisite infrastructure #43.
- Alexander corrected the assumption that the preservation hash would usually be empty and requested primary terminology; Herrera adjusted allocation sizing and wording, then landed the polished patch with light edits as ba25358413 and confirmed the backpatches #44 #45.
- Antonin Houska subsequently found that nested single quotes made the test's archive_command configuration invalid even though the test passed, and Alexander supplied a one-line quoting correction #47 #48.
- Herrera committed that correction with a matching comment update as b5be29ecaf and announced the push; the commit explains that checking only pg_rewind's diagnostic allowed the configuration error to escape detection #49.
- In July 2026, Alena Vinter reported that keepwal could retain stray segments from a target timeline higher than the source's, proposed clamping the recorded timeline to the source timeline, and reported a reproducing test that passed with the fix; this follow-up remains unreviewed and uncommitted in the supplied thread #50.