model-writtenrun 1893 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Mikhail Kot reported crashes under memory pressure caused by half-initialized shared statistics hash entries and proposed returning NULL on allocation failure with checks in callers and flush callbacks #1.
- Michael Paquier explained that the new flush-callback checks violated forced-flush semantics, advocated restoring shared-state consistency before raising an error, and corrected the affected-version range to PostgreSQL 15 onward #2; Ranier Vilela likewise favored ERROR over widespread NULL checks #6.
- Steven Niu questioned whether DSA users generally needed pointer checks #3, and Michael Paquier clarified that ordinary DSA allocation already throws an error and that this bug instead concerns shared state left inconsistent by that error #4.
- Mikhail Kot replaced the initial approach with exception handling that deletes the newly inserted hash entry before rethrowing an allocation error #7; Steven Niu raised concerns about NULL values reaching later operations #8 #11, which Michael Paquier and Rider explained were prevented by the error-handling control flow #9 #12.
- Michael Paquier supplied a new revision making pgstat_init_entry() explicitly return NULL on allocation failure so its two callers could handle the consequences, initially allowing startup to discard statistics with a warning, and attached a separate injection point for reproducing the failure #10.
- Michael Paquier subsequently rejected the startup warning because memory pressure should not discard on-disk statistics, requested restoring ERROR, and said the injection point should remain a testing aid; he also reconsidered backpatching because corruption could crash other sessions #14.
- Michael Paquier committed the main fix from #10 as 8191e0c16a, with startup ERROR behavior restored, comments and diagnostics adjusted, and the injection-point patch omitted; the change credits Mikhail Kot and was backpatched through PostgreSQL 15.
- The thread ended with Michael Paquier confirming that further corruption testing supported the chosen fix and that only small adjustments were needed for older branches, leaving the production fix landed and the testing-only injection point excluded #16.