BUG #19803: Assertion "!parallel_aware || pathnode->path.parallel_safe" in create_append_path
BUG #19803: Assertion "!parallel_aware || pathnode->path.parallel_safe" in create_append_path
От:
PG Bug reporting form <noreply@postgresql.org>
Дата:
The following bug has been logged on the website:
Bug reference: 19803
Logged by: Gowtham Reddy
Email address: gowthamdoma18@gmail.com
PostgreSQL version: 17.11
Operating system: Ubuntu 22.04 (WSL2), x86_64, built with --enable-c
Description:
On an assert-enabled build this query crashes the backend:
CREATE TABLE pi (a int);
CREATE TABLE pi_child () INHERITS (pi);
WITH c1 AS (SELECT 1 FROM pi WHERE true UNION ALL SELECT 1 FROM pi WHERE
false),
c2 AS MATERIALIZED (SELECT 1)
SELECT 1 FROM c1 UNION ALL SELECT 2 FROM c2;
TRAP: failed Assert("!parallel_aware || pathnode->path.parallel_safe"),
File: "pathnode.c", Line: 1439 (master 4848fd675; line 1328 on 17.11)
Reproduced on 17.11 and master (4848fd675, 2026-10-28), default settings.
A release build (18.6) returns the expected rows.
Needed: an inheritance parent with a child (a plain table does not crash);
the
inlined CTE being a UNION ALL with a constant-false branch (with only true
branches it does not crash); the outer UNION ALL including a MATERIALIZED
CTE
scan. Writing the first branch as a FROM subquery instead of a CTE does not
crash. It looks like a parallel-aware Append is built although one of its
children is not parallel-safe.
Found by a grammar-based SQL fuzzer (university course project); the script
above is the hand-reduced test case.
Re: BUG #19803: Assertion "!parallel_aware || pathnode->path.parallel_safe" in create_append_path
On Thu, 29 Oct 2026 at 05:25, PG Bug reporting form
wrote:
> CREATE TABLE pi (a int);
> CREATE TABLE pi_child () INHERITS (pi);
> WITH c1 AS (SELECT 1 FROM pi WHERE true UNION ALL SELECT 1 FROM pi WHERE
> false),
> c2 AS MATERIALIZED (SELECT 1)
> SELECT 1 FROM c1 UNION ALL SELECT 2 FROM c2;
>
> TRAP: failed Assert("!parallel_aware || pathnode->path.parallel_safe"),
> File: "pathnode.c", Line: 1439 (master 4848fd675; line 1328 on 17.11)
Thanks for reporting this. It looks like this happens because there's
a childrel with partial_paths that's marked as consider_parallel =
false. add_paths_to_append_rel() doesn't check if childrel has
consider_parallel == true before looking at the partial_pathlist. It
expects that's empty when the childrel is consider_parallel == false.
Looks like we can just delete the partial_pathlist when
consider_parallel gets set to false. That's what most other places do
when doing rel->consider_parallel = false; Check
apply_scanjoin_target_to_paths(). This doesn't seem to need to be done
in set_append_rel_size().
Draft patch attached.
David
Re: BUG #19803: Assertion "!parallel_aware || pathnode->path.parallel_safe" in create_append_path
От:
Gowtham Reddy <gowthamdoma18@gmail.com>
Дата:
Hi David,
Thanks for the quick analysis and the draft patch.
I applied it on master at 4848fd675 (assert-enabled build). The
reproducer from my report no longer crashes and returns the expected
row, also with debug_parallel_query = on. The original, larger test
case from the fuzzer that led to this report also runs without the
assertion failure, and "make check" passes.
Regards,
Gowtham
On Thu, 29 Oct 2026 at 06:52, David Rowley wrote:
>
> On Thu, 29 Oct 2026 at 05:25, PG Bug reporting form
> wrote:
> > CREATE TABLE pi (a int);
> > CREATE TABLE pi_child () INHERITS (pi);
> > WITH c1 AS (SELECT 1 FROM pi WHERE true UNION ALL SELECT 1 FROM pi WHERE
> > false),
> > c2 AS MATERIALIZED (SELECT 1)
> > SELECT 1 FROM c1 UNION ALL SELECT 2 FROM c2;
> >
> > TRAP: failed Assert("!parallel_aware || pathnode->path.parallel_safe"),
> > File: "pathnode.c", Line: 1439 (master 4848fd675; line 1328 on 17.11)
>
> Thanks for reporting this. It looks like this happens because there's
> a childrel with partial_paths that's marked as consider_parallel =
> false. add_paths_to_append_rel() doesn't check if childrel has
> consider_parallel == true before looking at the partial_pathlist. It
> expects that's empty when the childrel is consider_parallel == false.
> Looks like we can just delete the partial_pathlist when
> consider_parallel gets set to false. That's what most other places do
> when doing rel->consider_parallel = false; Check
> apply_scanjoin_target_to_paths(). This doesn't seem to need to be done
> in set_append_rel_size().
>
> Draft patch attached.
>
> David
Re: BUG #19803: Assertion "!parallel_aware || pathnode->path.parallel_safe" in create_append_path
От:
David Rowley <dgrowleyml@gmail.com>
Дата:
On Thu, 29 Oct 2026 at 14:32, Gowtham Reddy wrote: > I applied it on master at 4848fd675 (assert-enabled build). The > reproducer from my report no longer crashes and returns the expected > row, also with debug_parallel_query = on. The original, larger test > case from the fuzzer that led to this report also runs without the > assertion failure, and "make check" passes. Thanks for checking. I've pushed the patch and backpatched all the way to v14. David