Skip to content

Fix wrong result in parallel ChunkAppend#9388

Draft
akuzm wants to merge 6 commits intotimescale:mainfrom
akuzm:exclude-chunk
Draft

Fix wrong result in parallel ChunkAppend#9388
akuzm wants to merge 6 commits intotimescale:mainfrom
akuzm:exclude-chunk

Conversation

@akuzm
Copy link
Copy Markdown
Member

@akuzm akuzm commented Mar 10, 2026

Some fields were not initialized properly in case when there's no startup exclusion but runtime parent exclusion, which led us to excluding the chunks that actually match.

Refactor the way we work with the lists of the matched plans to prevent confusion. Now we use the same initial list of matched plans always, and keep a separate list of plan states (excluded/finished/etc) which is used for iteration.

Some fields were not initialized properly in case when there's no
startup exclusion but runtime parent exclusion, which led us to
excluding the chunks that actually match.

Refactor the way we work with the lists of the matched plans to prevent
confusion. Now we use the same initial list of matched plans always, and
keep a separate list of plan states (excluded/finished/etc) which is
used for iteration.
akuzm and others added 2 commits March 10, 2026 14:55
The test for parallel ChunkAppend with InitPlan params filtered on
column i (the partitioning column). This caused the planner to set
runtime_exclusion_children, which made it pick a Single Copy Gather
plan instead of a parallel-aware ChunkAppend. The shared-memory
subplan coordination path was never exercised, so the test passed
even with the buggy code.

Switch the filter to column j (non-partitioning column) so the
planner produces a truly parallel ChunkAppend with only
runtime_exclusion_parent. This correctly exposes the bug where
parallel workers received empty subplan lists from shared memory.

Verified on PG17 and PG18:
- Old code + new test: workers_ok = f (bug detected)
- Fixed code + new test: workers_ok = t (bug fixed)
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 10, 2026

Codecov Report

❌ Patch coverage is 95.72650% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/nodes/chunk_append/exec.c 95.72% 4 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

claude added 3 commits March 10, 2026 17:35
The partial and non-partial plan tests only ran EXPLAIN without
executing the query, so the worker code path that marks non-partial
plans as finished was never covered.  Add actual query execution to
exercise that path.
Cover the do_runtime_exclusion code path where
ts_chunk_append_get_scan_plan returns NULL for a MergeAppend child
in an ordered ChunkAppend with space partitioning. This exercises
the continue at exec.c:456 (scan == NULL skip).

The test creates a space-partitioned hypertable where one time slice
has data in both space partitions (producing a MergeAppend child)
and another has data in only one partition (producing a direct scan
child). A LATERAL join triggers runtime chunk exclusion, which must
handle both child types.
Shared tests run in parallel in the same database and must not create
new tables. Move to tsl/test/sql/ where each test gets its own database.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants