model-writtenrun 6909 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Amit Kapila opened the thread with a buildfarm failure reported by Peter Smith, and Tom Lane identified the failed zero-refcount assertion in pgstat_release_entry_ref() #1 #2.
- Alexander Lakhin supplied a sleep-assisted reproducer using repeated oldest_xmin tests, and Peter independently reproduced the failures after reverting the recently suspected transaction patch, clearing that change of responsibility #3 #4.
- After more than a year, Alexander returned with two focused replication-slot tests and traced the race: another backend reinitializes an entry after its reference count reaches zero but before the releasing backend acquires the hash lock #5.
- Michael Paquier connected the failure to OID reuse and proposed tracking an entry generation in both shared state and local references, accepting changes to internal structures to prevent stale references from deleting reused statistics #6.
- Michael posted the agecount implementation, acknowledged a similar earlier concept by Kyotaro Horiguchi, and reported successful concurrent slot testing; an automated isolation test was deferred pending injection-point integration #7.
- Kouber Saparev reported a PostgreSQL 15.4 standby terminating with a duplicate statistics-drop error, adding a production example while the fix remained under review #8 #10.
- Bertrand Drouvot tested the fix successfully and suggested locking before decrementing the reference count, while noting the shared entry grew from 32 to 40 bytes; Michael retained the counter approach because the alternatives introduced additional races or locking overhead #13 #14.
- Michael renamed agecount to generation and chose correctness over the structure-size concern; Bertrand endorsed the revised patch and requested consistent comment terminology while reopening the question of regression coverage #15 #16.
- Michael committed the revised patch as 818119afcc, with comment and locking-documentation edits, and backpatched through PostgreSQL 15; automated testing remained an open follow-up because reproducing the shutdown path required careful synchronization #15 #17.
- Kouber reported another duplicate-drop standby shutdown on PostgreSQL 17.3, and Michael noted that the relation OID was near wraparound #18 #19.
- Bertrand proposed exposing generation in the duplicate-drop error, Michael agreed, and Bertrand supplied the diagnostic patch #20 #21 #22.
- Michael committed that diagnostic patch unchanged as 84b32fd228 and backpatched through PostgreSQL 15 to gather better evidence from future failures #22 #23.
- Another shutdown led Kouber to identify the affected setup as a cascading standby; Michael requested relation, workload, and WAL details and recommended obtaining the new generation diagnostics #25 #26 #27 #28.
- Kouber confirmed hot_standby_feedback and heavy table creation and deletion, but Michael could not reproduce the failure with concurrent table churn, cascading-standby reads, and forced OID wraparound; duplicate drops in WAL remained a hypothesis #29 #30.
- In July 2026, Kouber reported another failure on PostgreSQL 17.6, now showing refcount=1 and generation=0, and Michael reiterated the need for a reproducible scenario #31 #32.
- Bertrand reproduced the failure by retaining a standby session's statistics reference while dropping two successive tables with the same forced OID; he found that the current stable branch no longer failed and attributed this to a separately backpatched change #33.
- Michael agreed that allowing missing entries during end-of-transaction drops could explain the improvement, while he and Bertrand discussed an OID-control testing facility without posting another patch here #34 #35.
- The thread ended with both submitted fixes landed, Kouber planning to try PostgreSQL 18.5, and Michael requesting follow-up because production resolution remained unconfirmed and failures could take months to recur #36 #37.