fix(server): handle repeated range predicates correctly - #3122
Conversation
imbajin
left a comment
There was a problem hiding this comment.
Blocking: yes. Summary: The query-lifetime range-match cache reuses an incomplete first-batch result and causes valid elements to be omitted. Evidence: three independent review lanes, exact-head static tracing, and repeated failures of VertexCoreTest.testRemoveLeftRangeIndex across memory, RocksDB, HBase, macOS, and HStore checks.
imbajin
left a comment
There was a problem hiding this comment.
Blocking: yes. Summary: The correctness fix introduces an allocation on every condition-filtered element, including queries that never use range-index bookkeeping. Evidence: exact-head static inspection and targeted memory-profile path analysis; the two focused correctness tests pass.
There was a problem hiding this comment.
Pull request overview
This PR fixes incorrect empty results when multiple has() predicates target the same range-indexed property (issue #3083), by preventing range-index validation from “consuming” the same index value multiple times during per-element filtering in ConditionQuery.
Changes:
- Cache range-index validation results per element + property while evaluating conditions, so repeated predicates on the same range-indexed property don’t invalidate otherwise-matching elements.
- Adjust
Element2IndexValueMap.checkRangeIndex()to accept a per-element cache map and reuse previously computed match outcomes for the same property. - Add a regression test covering repeated predicates and reversed predicate order.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/EdgeCoreTest.java | Adds a regression test for repeated range predicates on the same edge property. |
| hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/query/ConditionQuery.java | Introduces per-element caching for range-index validation to avoid double-consuming index values for repeated predicates. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
imbajin
left a comment
There was a problem hiding this comment.
Blocking: no. Summary: The cross-batch correctness and non-index allocation regressions are fixed; the remaining range-index allocation concern is already covered by an existing thread, so no duplicate inline comment is added. Evidence: three independent exact-head review lanes, EdgeCoreTest ran 169 tests with 0 failures/errors and 11 skipped, and visible exact-head checks are green.
Purpose of the PR
Fix incorrect empty results when multiple predicates target the same range-indexed property.
Main Changes
Verifying these changes
mvn test -pl hugegraph-server/hugegraph-test -am -P core-test,rocksdb -Dtest=EdgeCoreTest -DfailIfNoTests=falseDoes this PR potentially affect the following parts?
Documentation Status
Doc - TODODoc - DoneDoc - No Need