model-writtenrun 7539 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Kurt Roeckx reported steadily increasing memory consumption and allocation failures in Synapse database connections after upgrading from PostgreSQL 9.5 to 12 #1.
- Tom Lane requested memory-context statistics, whose small allocation totals suggested the growth occurred outside palloc; Andres Freund requested Linux resident-memory breakdowns, and Kurt's measurements confirmed growing anonymous allocations rather than shared-buffer residency #2 #3 #4 #5 #7 #9.
- Andres Freund suspected a known JIT/LLVM leak and proposed disabling JIT; Kurt confirmed that memory consumption stabilized, then tested Andres's narrower suggestion of disabling only inlining and again observed no leak #10 #13 #14 #15 #16.
- Laurent Mignon reported residual growth despite disabling inlining, which Andres treated as a separate issue requiring diagnostics; Andres also explained that his prototype fix remained incomplete and a hand injury had slowed progress #17 #18.
- Jaime Casanova reported encountering the problem again in April 2021 and asked about documentation, while Andres said he had two mostly working fixes to revisit after the release freeze #19 #20.
- Andres explained that LLVM's destructive IR linker forces module reloads that create fresh structural types, and chose periodic LLVM-context replacement as the practical backpatchable solution; a nondestructive linker promised better performance but required too much new code, while a fresh context for every query would impose excessive reload costs #21.
- The thread ended with Andres's four-patch draft making context references explicit, cleaning up declarations, and recycling the context after a 10000-use threshold when no JIT contexts remained active; naming, helper extraction, and refinement of the recycling trigger remained unfinished, with no subsequent review or landing shown here #21.
- The eventual fix landed as 9dce22033d through the later matching submission #686873 in thread #71555, credited to Andres Freund and Daniel Gustafsson, with helper extraction and a reduced recycling threshold of 100.