model-writtenrun 7623 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Tom Lane opened the thread with experimental changes that reduced Valgrind noise by retaining pointers, moving list links to allocation starts, removing catcache alignment and allocating dynahash entries individually; he explicitly described the patch as unsuitable for direct commit #1.
- Andres Freund's testing exposed an unfreed parallel-scan allocation and questioned its placement in the generic scan descriptor #2; he and Tom agreed that reachable storage was acceptable, while Tom argued that scans should not run in long-lived cache contexts #6 #7.
- Andres demonstrated that failed PL/pgSQL compilation leaked function contexts and uncovered a separate snapshot-caching performance regression caused by failing to advance xactCompletionCount on subtransaction abort #8; Tom suggested temporary contexts followed by reparenting, while prioritizing non-error cases #9.
- Andres supplied a complementary patch that registered memory-context headers as Valgrind allocations, moved pool lifecycle operations into the allocators and used pool trimming on reset #11; Tom accepted that division of responsibility and requested explanatory comments #12.
- Inspection of Valgrind showed that a malloc region containing pool allocations is excluded from ordinary leak traversal, explaining why context-header pointers disappeared; Tom and Andres also discussed preserving copied context identifiers across resets without settling an implementation #12 #13.
- Andres identified error-path string leakage in call_string_check_hook #13, while Tom traced parallel-worker leakage to RestoreGUCState reinitializing GUCs and losing their allocations #14; the necessity and semantics of that initialization remained unresolved #15 #16 #18.
- Tom and Andres independently narrowed the relcache problem to RelationInitTableAccessMethod running in CacheMemoryContext, and Andres used assertions to find additional scans in permanent contexts #16 #17; both considered postponing broader cleanup, although Andres still wanted the PL/pgSQL error leak addressed #18 #19.
- Tom then posted an expanded cleanup patch that, combined with Andres's allocator patch, removed nearly all core regression-test leak warnings; he separated repeatable genuine leaks from diagnostic workarounds and lower-priority cache waste #20.
- The rd_statlist cleanup from #20 landed unchanged as 28644fac10, freeing the list when its relcache entry is destroyed.
- The GUC error-path fixes from #20 landed with a comment adjustment as 377b7a8300, excluding the experimental RestoreGUCState change.
- The ispell regex cleanup from #20 landed with naming and comment edits as d303849b05, using context callbacks to free compiled regexes.
- The libpq connection-string error cleanup from #20 landed unchanged as 9bacdf9f53, and its relcache context-switch fix landed with comment wrapping as 415ffdc220; all five extracted leak fixes were backpatched.
- David Rowley returned with a separate patch moving parallel-worker state into HeapScanDescData, allocating it only for parallel scans and freeing it at scan end #21; Andres approved it while noting that the long-lived-context leak was already fixed #22.
- David committed that patch unchanged as af527705ed and confirmed the push in the thread's final message #23.
- At the close, the five extracted leak fixes and parallel-scan cleanup had landed, but the broader Valgrind instrumentation and workarounds remained unfinished here; Tom's last assessment still left PL/pgSQL suppression, dictionary initialization leaks, a replication-worker handle leak and a puzzling lock-owner warning unresolved #20 #23.