Repository navigation
Conversation
Rewriting a query's global time filter combination allocated new filters and expressions that were registered in QueryExpression's ownership lists while also becoming the query's expression_ tree, so closing the result set freed the same objects two or three times. A single filter instance was also shared across every series leaf when a global OR was pushed down. Optimization now consumes the input tree and leaves exactly one owner for the result: combined filters reuse the parent node, per-leaf copies come from a new Filter::clone(), and detached nodes are released on failure. The executor clears expression_ when optimization fails so a later close cannot delete the already-consumed tree. Add end-to-end coverage for AND/OR with a global time filter, two global filters, multi-series OR pushdown, empty branches, clone failures, and direct AndFilter/OrFilter semantics. expression.cc: 34.5% -> 73.6%, or_filter.h: 0% -> 76.0%, and_filter.h: 40.0% -> 72.3%.
BinaryFilter never released its operands, so every AndFilter/OrFilter created while optimizing a global time filter leaked the filters it wrapped, and their get_time_ranges() results leaked the child TimeRange objects. LeakSanitizer flagged both in the new expression tests. Own the operands in BinaryFilter, free the temporary child ranges in AndFilter/OrFilter::get_time_ranges(), and heap-allocate the operands in the logical-filter unit test now that the wrapper owns them. Also guard OrFilter::get_time_ranges() against both children being empty.
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.
Summary
Queries that combine a global time filter with series expressions (
AND/ORaround aGLOBALTIME_EXPR) had 0% test coverage and were in fact broken:QueryExpression::optimize()created filters/nodes, registered them inmy_exprs_/my_filters_, and handed the same objects back asexpression_, so closing the result set freed them two or three times. When a globalORwas pushed down, oneFilterinstance was also shared by every series leaf. A standalone probe (AND/OR with a global filter, two global filters) segfaulted in all three shapes.The optimization now consumes the input tree and leaves exactly one owner for the result:
AND/ORnode and transfers both filters into the combined oneFilter::clone()(implemented by all time operators and byAndFilter/OrFilter); a filter that cannot be cloned fails the optimization instead of being sharedTsFileExecutorclearsexpression_when optimization fails so a later close cannot delete the consumed treeNew tests:
cpp/test/reader/global_time_filter_test.cc: OR/AND of a global filter with series filters, two global filters, multi-seriesORpushdown,ANDover anORof series, and empty branchescpp/test/reader/filter/logical_filter_test.cc: directAndFilter/OrFilterpredicate, pruning, range-union/intersection and batch semanticscpp/test/reader/expression_test.cc: clone-failure paths and the documented consume-on-failure contractCoverage:
expression.cc34.5% -> 73.6%,or_filter.h0% -> 76.0%,and_filter.h40.0% -> 72.3%.Test plan
./mvnw -B clean verify -P with-java,with-python -Denable.lzma2=ON(Java, C++, Python; 1862 C++ tests passed)./mvnw -B clean verify -P with-cpp -Denable.asan=ON -Dbuild.type=RelWithDebInfo -Denable.lzma2=ON(1863 tests, 0 failed; macOS run used the Xcode 26.6 toolchain withASAN_OPTIONS=detect_container_overflow=0for the uninstrumented ANTLR runtime)./mvnw spotless:check -P with-java,with-python