You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "dojiong (via GitHub)" <gi...@apache.org> on 2025/12/09 09:40:03 UTC
[PR] fix: stack overflow when loading large equality deletes [iceberg-rust]
dojiong opened a new pull request, #1915:
URL: https://github.com/apache/iceberg-rust/pull/1915
## Which issue does this PR close?
- Closes #.
## What changes are included in this PR?
A stack overflow occurs when processing data files containing a large number of equality deletes (e.g., > 6000 rows).
This happens because parse_equality_deletes_record_batch_stream previously constructed the final predicate by linearly calling .and() in a loop:
```rust
result_predicate = result_predicate.and(row_predicate.not());
```
This resulted in a deeply nested, left-skewed tree structure with a depth equal to the number of rows (N). When rewrite_not() (which uses a recursive visitor
pattern) was subsequently called on this structure, or when the structure was dropped, the call stack limit was exceeded.
Changes
1. Balanced Tree Construction: Refactored the predicate combination logic. Instead of linear accumulation, row predicates are collected and combined using a
pairwise combination approach to build a balanced tree. This reduces the tree depth from O(N) to O(log N).
2. Early Rewrite: rewrite_not() is now called immediately on each individual row predicate before they are combined. This ensures we are combining simplified
predicates and avoids traversing a massive unoptimized tree later.
3. Regression Test: Added test_large_equality_delete_batch_stack_overflow, which processes 20,000 equality delete rows to verify the fix.
## Are these changes tested?
- [x] New regression test test_large_equality_delete_batch_stack_overflow passed.
- [x] All existing tests in arrow::caching_delete_file_loader passed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] fix: stack overflow when loading large equality deletes [iceberg-rust]
Posted by "liurenjie1024 (via GitHub)" <gi...@apache.org>.
liurenjie1024 commented on code in PR #1915:
URL: https://github.com/apache/iceberg-rust/pull/1915#discussion_r2605965545
##########
crates/iceberg/src/arrow/caching_delete_file_loader.rs:
##########
@@ -374,10 +374,27 @@ impl CachingDeleteFileLoader {
row_predicate = row_predicate.and(cell_predicate)
}
}
- result_predicate = result_predicate.and(row_predicate.not());
+ row_predicates.push(row_predicate.not().rewrite_not());
}
}
- Ok(result_predicate.rewrite_not())
+
+ while row_predicates.len() > 1 {
Review Comment:
Please add a comment to explain why we need to do this optimization.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] fix: stack overflow when loading large equality deletes [iceberg-rust]
Posted by "liurenjie1024 (via GitHub)" <gi...@apache.org>.
liurenjie1024 merged PR #1915:
URL: https://github.com/apache/iceberg-rust/pull/1915
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org