model-writtenrun 8001 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Luis Roberto, posting as Noname, reported that enabling incremental sort on PostgreSQL 13 crashed a parallel worker #1; after difficulties obtaining debug symbols, he supplied a self-contained reproducer involving DISTINCT and correlated subqueries #8.
- Tom Lane traced the crash to parallel-unsafe subplans in sort expressions: the planner placed IncrementalSort below Gather, serialization omitted those subplans, and workers dereferenced missing plan state #9.
- Tom Lane attached a defensive executor check to turn the crash into an error #9, while Luis Roberto adopted disabling incremental sort as a workaround #10.
- James Coleman suggested that the underlying planner bug could affect ordinary sorts too because sorts were now considered in more places below Gather #11; Tom Lane suspected sort expressions could escape the relation-target checks that normally establish parallel safety #12.
- Tom Lane committed the executor guard from #9 unchanged as 92f87182f2, backpatching through PostgreSQL 10; James Coleman's general approval in #11 did not demonstrate substantive review of that patch.
- James Coleman questioned the blanket restriction on correlated subplans #13, and Amit Kapila explained the difficulties of passing changing parameters to workers #14; James then identified cases where all required values would already be local to each worker #16.
- Amit Kapila agreed that worker-local cases might be supportable but called for explicit safety analysis #18; James Coleman traced the restriction to parameter checks and proposed reconsidering safety in the enclosing execution context #19.
- James Coleman separated the PostgreSQL 13 bugfix, which would reject unsafe sort expressions, from possible PostgreSQL 14 work to permit safe correlated subplans using additional parameter-aware checks #21.
- Amit Kapila cautioned that determining where parameters are generated is difficult #22; the thread ended with James Coleman reporting promising exploratory work that he intended to post separately, without an attached implementation here #23.
- The underlying planner fix subsequently landed as 86b7cca72d from the later patchset #464814 in thread #43279, adding parallel-safety checks for useful sort expressions and regression tests, with a backpatch to PostgreSQL 13.