model-writtenrun 8446 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Sami Imseih restarted the proposal in #1 with an on-demand SQL API that could signal another backend and a local C API, aiming to expose statistics during long transactions while deferring transaction-dependent counters.
- After a gap and discussion in the pg_stat_statements scalability thread, Sami returned with #2, replacing the new signaling API with pg_stat_force_next_flush() and adopting explicit transaction context and distinct callback outcomes attributed to Kyotaro and Bertrand; automatic statement-boundary flushing remained only a demonstration.
- Bertrand Drouvot found that immediate flushing could free storage still referenced by active function calls in #3, prompting #4 to retain pending entries and add regression coverage.
- Bertrand then demonstrated delayed database aggregates, double-counted function timing, and cleared transaction-local counters in #5; Sami responded in #8 with cumulative counters, flushed baselines, transaction-aware static callbacks, and repeated dependency scans.
- Following Bertrand's cascade and accounting review in #9, Sami replaced the extension-controlled rescan flag with transparent pending-entry requeueing in #10, corrected ANALYZE and truncate handling, and separated the experimental cascade tests into a nocfbot attachment.
- Further review in #11 led to #12, which adapted the patch to separate index statistics, corrected timing precision and custom-counter clearing, avoided unnecessary locks, and guarded against recursive flushing; Sami retained caller-controlled throttling.
- Bertrand's error-cleanup and unnecessary-lock findings in #13 opened a counter-layout discussion, and Michael Paquier endorsed separating transactional data in #17; Sami split the work into a preparatory refactoring and the flushing feature in #18, also adding PG_FINALLY cleanup.
- Bertrand identified unsafe padding assumptions and an error window during dependent database updates in #19; #22 moved truncdropped outside the counters, added padding assertions and truncate-only coverage, and introduced a separate database-preparation patch while shelving the custom reset example.
- After Bertrand found another interrupt window in #23, Sami proposed moving the pre-existing consistency problems to a separate thread in #24, Bertrand agreed in #25, and #26 withdrew that prerequisite rather than landing it.
- Reviews in #27 and #29 refined pending-entry tracking: #28 reset stale flags and prohibited self-preparation, then #30 adopted generation counters to avoid the extra reset scan despite benchmarks showing no measurable regression.
- Bertrand noticed missing cleanup for the new truncation test in #31, which Sami supplied in #32; Michael independently verified the test exposed otherwise-undetected loss of live/dead resets and extracted it with light edits as ac00b0f8bd, explaining the decision in #33.
- Sami resent the remaining work in #34, and Michael revised its prerequisite in #35 to place counts_xact directly beside the nontransactional counters, use established xact naming, and remove unrelated custom-statistics changes.
- Michael also proposed documenting the existing flush function independently in #36; Sami supplied revised wording in #38, which landed unchanged as c8985a09b7.
- After Sami accepted Michael's refactoring in #37, the patch from #35 landed unchanged as 3f2f5e7c4c, with Sami retaining authorship.
- Sami posted the remaining mid-transaction flushing feature in #41, adapting it to the committed counter layout and extending the newly added documentation.
- Intermittent CI assertions revealed that a FATAL during flushing could enter the shutdown hook before cleanup ran; #42 prevented recursive shutdown flushing and discarded pending entries on that exit path.
- Following the rebase in #43, Sami supplied another mandatory rebase in #44 without changing the implementation.
- Bertrand demonstrated in #45 that a procedure could commit an insert, start another transaction, and force a flush while the committed insert count remained invisible; he suggested flushing before the procedure began its next transaction.
- Sami answered in #46 that counts_xact already held finalized counts, so he removed the relation callback's transaction-state gate instead of adding automatic flushing at every procedure COMMIT, moved HOT and new-page update counts into per-transaction state, and added a regression test confirming that only the completed transaction's counts become visible.
- The same revision in #46 removed CHECK_FOR_INTERRUPTS() from the flush loop to avoid cancellation errors after query completion, restored accidentally removed custom-statistics reset coverage, and clarified the API's usefulness for long-running transactions and extensions; partial-flush support remained for custom statistics kinds.
- Zsolt Parragi demonstrated in #47 that flushing aborted inserts after TRUNCATE incorrectly reduced n_ins_since_vacuum and requested clearer subtransaction documentation; Bertrand then showed stale dead-tuple counts after committed TRUNCATE followed by ANALYZE and proposed retaining interrupt checks during transactional flushes in #48.
- Sami addressed both reviews in #49, preserving previously flushed inserts when resetting ins_since_vacuum, resetting live/dead baselines alongside counts at ordinary and prepared commit, adding aborted-savepoint regression coverage, and restoring interrupt checks only inside transactions; the documentation now distinguishes top-level commit from subtransaction rollback.
- Bertrand found in #50 that reversing the order to abort and flush inserts before TRUNCATE still left n_ins_since_vacuum at five instead of zero; Sami identified this as an existing HEAD bug in #51, and Bertrand confirmed its older origin and volunteered a dedicated thread in #53.
- At #53, the truncation test, documentation, and counter refactoring have landed, while the main mid-transaction flushing feature remains under review at #49, with the pre-existing reverse-order TRUNCATE accounting bug deferred to a separate discussion.