model-writtenrun 4258 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Tomas Vondra reported that generated-column support had introduced per-row bitmap allocations retained in ExecutorState, potentially consuming gigabytes during UPDATE, and proposed explicit bitmap frees plus a separate PL/pgSQL workspace cleanup #1.
- Tom Lane and Andres Freund argued that shorter-lived memory contexts were preferable to manual freeing, because caller-side cleanup would leave the surrounding code vulnerable to future leaks #2 #3 #17.
- The discussion also explored detecting executor memory growth and locating allocations with profiling tools; Jakub Wartak supplied perf observations from the original problem, while Tom and Andres described Valgrind and heaptrack techniques, but no instrumentation patch emerged #5 #10 #15 #17.
- Tomas revised the series to switch into GetPerTupleMemoryContext around bitmap-producing calls, retaining the original cleanup patches while expressing concern about other allocations requiring longer lifetimes #13.
- Tom's instrumentation showed that PL/pgSQL datum copies already used SPI Proc, and Tomas could not reproduce the alleged leak; a failing debugger breakpoint condition likely explained both the datum and expanded-record suspicions, so those cases were set aside #14 #16.
- Andres identified a cached partition-map lifetime hazard in broader context switching and suggested a context-switching helper variant; he also proposed avoiding repeated bitmap computation, which Tomas deferred as a separate optimization #18 #22 #26.
- Tomas realized that ExecGetAllUpdatedCols already received EState and replaced the caller-side changes with a single internal per-tuple context switch, while noting the potential impact on callers expecting a longer-lived result #25.
- The bitmap fix landed from that simplified patch with a new caller-lifetime comment in f24523672d and its separately supplied PostgreSQL 15 backport ee87f8b63a; Tomas announced the landing and left bitmap caching for separate work #27.
- Alexander Pyhalov then demonstrated broken tg_updatedcols access in AFTER UPDATE triggers, and Tomas recognized that saved trigger events retained a bitmap whose per-tuple context had already been reset #28 #29.
- Tomas supplied a follow-up patch copying the bitmap into AfterTriggerEvents, and Alexander confirmed that the patch fixed his reproducer and looked good #30 #31.
- The follow-up landed as ce5aaea8cd with only an expanded helper comment; Tomas confirmed backpatching through PostgreSQL 13, explained that PostgreSQL 12 lacked the affected saved bitmap, and closed with bitmap caching still deferred to a separate patch #32.