Re: BUG #18902: TRAP:: failed Assert("!is_sorted") in File: "createplan.c"
David Rowley <dgrowleyml@gmail.com>
From: David Rowley <dgrowleyml@gmail.com>
To: Richard Guo <guofenglinux@gmail.com>
Cc: Tender Wang <tndrwang@gmail.com>, n.kalinin@postgrespro.ru, pgsql-bugs@lists.postgresql.org
Date: 2025-04-27T00:14:08Z
Lists: pgsql-bugs
On Fri, 25 Apr 2025 at 14:16, Richard Guo <guofenglinux@gmail.com> wrote: > Hmm, well, I don't think we can get rid of MergePath.outersortkeys and > innersortkeys, even if we've cached the number of presorted keys for > the outer and inner paths. These fields represent the desired > ordering to be produced by an explicit Sort node — not the current > ordering of the outer or inner path. Without this information, how > would create_mergejoin_plan know what sort order to generate for the > outer and inner paths if they are not already sorted? I misspoke about getting rid of the two List fields. > Maybe we could cache the number of presorted keys for the outer and > inner paths in MergePath to save some pathkeys_count_contained_in > calls. But I'm not too sure it's worthwhile. The pathkeys are > canonical, and can be checked for equality by simple pointer > comparison. So it does not seem to cost too much. Besides, the > "redundant" pathkey checks actually helped uncover the bug we're > discussing here — didn't they? I don't see any reason why we couldn't keep an Assert to ensure the sorted-ness of the Path matches our expectations. Calculating the whole thing again in non-assert builds seems a bit silly. The previous code took care to avoid recalculations by nullifying the Lists when no sort was required, you've not followed that with the incremental sort changes, and to me, that makes it feel a little half-done. David
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Track the number of presorted outer pathkeys in MergePath
- c06e909c26f0 18.0 landed
-
Suppress unnecessary explicit sorting for EPQ mergejoin path
- 773db22269d4 18.0 landed
-
Re-enable SSL connect_fails tests, and fix related race conditions.
- e0f373ee42a4 18.0 cited
-
Consider explicit incremental sort for mergejoins
- 828e94c9d2fd 18.0 cited