BUG #19803: Assertion "!parallel_aware || pathnode->path.parallel_safe" in create_append_path

Started by PG Bug reporting form27 days ago4 messagesbugs
Jump to latest
#1PG 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.

#2David Rowley
dgrowleyml@gmail.com
In reply to: PG Bug reporting form (#1)
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
<noreply@postgresql.org> 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

Attachments:

t254428_2
nullify_partial_pathlist_when_unsetting_consider_parallel.patchapplication/octet-stream; name=nullify_partial_pathlist_when_unsetting_consider_parallel.patchDownload+6-1
#3Gowtham Reddy
gowthamdoma18@gmail.com
In reply to: David Rowley (#2)
Re: BUG #19803: Assertion "!parallel_aware || pathnode->path.parallel_safe" in create_append_path

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

Show quoted text

On Thu, 29 Oct 2026 at 06:52, David Rowley <dgrowleyml@gmail.com> wrote:

On Thu, 29 Oct 2026 at 05:25, PG Bug reporting form
<noreply@postgresql.org> 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

#4David Rowley
dgrowleyml@gmail.com
In reply to: PG Bug reporting form (#1)
Re: BUG #19803: Assertion "!parallel_aware || pathnode->path.parallel_safe" in create_append_path

On Thu, 29 Oct 2026 at 14:32, Gowtham Reddy <gowthamdoma18@gmail.com> 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