fix: handle empty batch from deletion in add_columns_from_stream#7233
Open
zhangyang0418 wants to merge 1 commit into
Open
fix: handle empty batch from deletion in add_columns_from_stream#7233zhangyang0418 wants to merge 1 commit into
zhangyang0418 wants to merge 1 commit into
Conversation
When an entire read batch has been deleted (e.g., all rows in a batch fall within the deletion vector), the updater yields a 0-row batch. The old code would then skip the inner loop, leaving `batches` empty, causing `concat_batches(&batches[0]..)` to panic with 'index out of bounds: the len is 0 but the index is 0'. This fix detects the empty batch case and feeds an empty batch back to the updater to keep it in sync, then continues to the next batch. Adds a regression test that creates a dataset with 105 rows, deletes the trailing 5 rows (forming a fully-deleted trailing batch when read with batch_size=50), and verifies add_columns succeeds. Fixes the panic reported in production when using merge_columns on a dataset with deletion files where deleted rows cluster at batch boundaries.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes a panic in
add_columnswhen a fragment's deleted rows fill an entire read batch.Closes #7232.
Root cause
In
add_columns_from_stream, the updater reads each fragment in physical batches and applies the deletion vector viafilter_record_batch. When every row in a physical batch is deleted, the filter yields a 0-row batch. The outer loop then setsrows_remaining = 0, the innerwhile rows_remaining > 0loop never runs,batchesstays empty, andconcat_batches(&batches[0].schema(), ..)panics withindex out of bounds: the len is 0 but the index is 0.This was hit in production using a merge-columns workflow over a dataset whose fragment had a deletion file, where the deleted rows happened to align with a read-batch boundary.
Fix
When the updater yields a 0-row batch, feed an empty batch back to the updater (to keep it in sync) and continue:
Test
Adds
test_add_columns_with_fully_deleted_batch: writes a single fragment with 105 rows, deletes the trailing 5 rows so that — read withbatch_size=50— the last batch[100..105)is fully deleted, then verifiesadd_columnssucceeds and the new column has the correct values. The test panics on the unpatched code and passes with the fix.