model-writtenrun 8994 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Jerry Sievers reported a reproducible PostgreSQL 9.6.14 segmentation fault in #1, and Tomas Vondra suspected an invalid parallel-scan shared-memory pointer in #2; disabling parallelism avoided the crash in #3.
- Using Jerry's debugger trace in #16, Thomas Munro identified Limit's early shutdown of Gather as destroying shared memory needed for a subsequent rescan in #17, then supplied a reproducer in #20.
- Amit Kapila proposed collecting worker instrumentation without destroying shared memory in #21, and Thomas considered a shutdown argument distinguishing final cleanup in #23, but Tom Lane insisted that nodes must support rescans until ExecEndNode and warned against a broad backpatched redesign in #24.
- Moving cleanup to executor end encountered the assertion forbidding active parallel contexts when leaving parallel mode in #26; Thomas later withdrew his proposed EXEC_FLAG_DONE workaround and reported that removing Limit's shutdown call also eliminated resource-leak warnings on newer branches in #29.
- Vignesh C submitted #34, delaying parallel-context destruction until ExecEndGather and moving the assertion; Amit identified remaining cleanup and assertion problems in #35, while Robert Haas highlighted missing Gather Merge changes and rejected weakening the shutdown contract in #36.
- Robert proposed removing Limit's early shutdown while investigating end-of-execution cleanup in #36; Tom explained in #44 that safely restoring early release would require executor promises and propagated rescan flags affecting external callers and extensions, making it unsuitable for a backpatched fix.
- Amit replaced the original approach with #47, removing the early shutdown call and providing a separate regression test while explicitly deferring the larger executor redesign.
- Amit merged the fix and test in #48 and ordered the inner scan through Gather Merge for deterministic results, explaining that the test could cover PostgreSQL 10 onward while the code fix could extend to 9.6; a suspected destination-close cleanup issue remained deferred without a reproducer.
- Robert requested clearer explanations and code comments in #50; Thomas tested the proposed change and drafted revised commit text in #51, and Amit clarified in #52 that losing instrumentation remained possible even without rescans when Limit stops consuming rows early.
- Amit posted #53 with the revised explanation and a nodeLimit.c comment documenting why early shutdown must wait for better rescan information, leaving the fix and regression behavior unchanged.
- Amit committed #53 unchanged as 080313f829, with backports through PostgreSQL 9.6, and confirmed the push in the final message #55; the crash fix landed, while accurate instrumentation with safe early resource release remained future work.