| From: | Sami Imseih <samimseih(dot)pg(at)gmail(dot)com> |
|---|---|
| To: | Lukas Fittl <lukas(at)fittl(dot)com> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de> |
| Subject: | Re: Assert failure in parallel query due to SubPlan double visit for hash join |
| Date: | 2026-10-29 00:17:26 |
| Message-ID: | CAN12+YKp==2DfwQ0pZE6LecoVW5PtsdZ7ukS5g+PHU9yUrkgdg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Lukas,
> The assertion failure happens because ExecParallelInitializeDSM visits
> that Sort twice and tries to shm_toc_insert() the same plan_node_id
> key.
I confirmed this also on an assert build.
> The instrumentation issue happens because (1) for loops, we
> accumulate the worker instrumentation twice in
> ExecParallelReportInstrumentation and then again in
> ExecParallelRetrieveInstrumentation for the nodes underneath the
> shared SubPlan, (2) for "Sort Method" the leader and workers end up
> pointing at different (duplicate) SharedSortInfo slots and the leader
> looks at the empty one.
In a non-assert build, this kind of case is definitely not easy to spot,
unless someone is really scrutinizing these parts of the plan.
Your patch looks fine to me. I just had a few small comments:
1/ Maybe rename planstate_tree_collect() to something like
planstate_tree_collect_distinct(). The important part here is that each
distinct PlanState appears in the returned list only once, so the name should
probably say that.
2/ Some execParallel.c comments still read as if the functions recurse. For
example ExecParallelRetrieveInstrumentation(),
ExecParallelReportInstrumentation(),
and ExecParallelInitializeWorker() now only deal with a single
PlanState at a time.
--
Sami Imseih
Amazon Web Services (AWS)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2026-10-29 00:23:38 | Re: Fix stale relcache fields for TOAST indexes during REINDEX CONCURRENTLY |
| Previous Message | jian he | 2026-10-28 23:56:42 | Re: SQL/JSON DEFAULT ON ERROR/ON EMPTY evaluation fail should rethrow error unconditionally |