Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error: invalid child of chunk append #7514

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

erimatnor
Copy link
Contributor

@erimatnor erimatnor commented Dec 3, 2024

When doing startup and runtime chunk exclusion, the chunk append node could sometimes throw an error: "invalid child of chunk append: Sort". Unfortunately, this error hasn't been successfully reproduced in a test but has been reported by users.

However, it seems clear that the error happens in
ts_chunk_append_get_scan_plan() when it can't find a "known" plan node to use for chunk exclusion. This function should ideally never throw and error and instead just return NULL, which means that chunk append falls back to not doing any exclusion instead of throwing an error.

It is also possible to improve the code and make it properly handle Sort and Result nodes by not special-casing them. By inspecting ts_chunk_append_get_scan_plan(), it is clear that it can only throw the error if it encounters a Result node with a Sort child, because in those two cases it didn't descend down the lefttree child node using a recursive call. Therefore, remove the special case and instead do a recursive call similar to how other nodes are handled. Also remove the special case for the vector agg node, since it should be OK to recursively process all CustomScan nodes.

@erimatnor erimatnor added the bug label Dec 3, 2024
@erimatnor erimatnor force-pushed the fix-chunk-append-error branch 2 times, most recently from 50e8cd8 to c21e648 Compare December 3, 2024 16:01
When doing startup and runtime chunk exclusion, the chunk append node
could sometimes throw an error: "invalid child of chunk append:
Sort". Unfortunately, this error hasn't been successfully reproduced
in a test but has been reported by users.

However, it seems clear that the error happens in
ts_chunk_append_get_scan_plan() when it can't find a "known" plan node
to use for chunk exclusion. This function should ideally never throw
and error and instead just return NULL, which means that chunk append
falls back to not doing any exclusion instead of throwing an error.

It is also possible to improve the code and make it properly handle
Sort and Result nodes by not special-casing them. By inspecting
ts_chunk_append_get_scan_plan(), it is clear that it can only throw
the error if it encounters a Result node with a Sort child, because in
those two cases it didn't descend down the lefttree child node using a
recursive call. Therefore, remove the special case and instead do a
recursive call similar to how other nodes are handled. Also remove the
special case for the vector agg node, since it should be OK to
recursively process all CustomScan nodes.
Copy link

codecov bot commented Dec 3, 2024

Codecov Report

Attention: Patch coverage is 20.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 82.19%. Comparing base (59f50f2) to head (c3a271b).
Report is 639 commits behind head on main.

Files with missing lines Patch % Lines
src/nodes/chunk_append/planner.c 20.00% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7514      +/-   ##
==========================================
+ Coverage   80.06%   82.19%   +2.12%     
==========================================
  Files         190      230      +40     
  Lines       37181    43188    +6007     
  Branches     9450    10867    +1417     
==========================================
+ Hits        29770    35498    +5728     
- Misses       2997     3372     +375     
+ Partials     4414     4318      -96     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant