Skip to content

fix(core): keep later ranges local after barrier - #3483

Merged
imbajin merged 1 commit into
apache:masterfrom
alexMarian704:fix-range-after-barrier
Nov 19, 2026
Merged

imbajin merged 1 commit into
apache:masterfrom
alexMarian704:fix-range-after-barrier

Conversation

@alexMarian704

Copy link
Copy Markdown
Contributor

Purpose of the PR

g.V().range(2, 3).barrier().range(0, 1) throws Invalid range: [2, 1) instead of returning 1 vertex.

extractRange() walks past the barrier and pushes both ranges into the same Query, so Query.range() treats the second range as if it was on the original stream. Only the first range should go to the backend, the second one applies to what's left after the first.

While testing I found two more cases with the same cause that don't throw but return wrong results:

  • g.V().range(1, 6).barrier().range(3, 8) returns 3 vertices instead of 2
  • g.V(id).out().range(2, 3).barrier().range(0, 1) returns 0 instead of 1

Main Changes

  • extractRange() now stops after the first range step, the rest stay as normal local range steps
  • removed the RangeGlobalStep check from the loop condition since it can't be reached anymore
  • added tests in VertexCoreTest and EdgeCoreTest for the cases above

Adjacent ranges like range(1, 6).range(4, 8) aren't affected, TinkerPop merges them before our strategy runs.

Verifying these changes

  • Trivial rework / code cleanup without any test coverage. (No Need)
  • Already covered by existing tests, such as (please modify tests here).
  • Need tests and can be verified as follows:
    • new tests fail on master and pass with the fix
    • ran CoreTestSuite and UnitTestSuite locally on the memory backend, all passing

Does this PR potentially affect the following parts?

Documentation Status

  • Doc - TODO: required documentation is pending; complete it before merging.
  • Doc - Done: documentation is included here or linked below.
  • Doc - No Need: no user-visible documentation is affected.

Documentation files in this PR or paired hugegraph-doc PR:

- push only the first range step into the backend query
- keep later ranges after a barrier as local steps
- fix Invalid range and wrong counts for g.V() ranges
- fix empty results for out() ranges after a barrier
- add regression tests in VertexCoreTest and EdgeCoreTest

Fixes apache#2216
@codecov

codecov Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 58.52%. Comparing base (8828d82) to head (07b904e).

Files with missing lines Patch % Lines
...he/hugegraph/traversal/optimize/TraversalUtil.java 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             master    #3483     +/-   ##
===========================================
  Coverage     58.52%   58.52%             
- Complexity     2717     7299   +4582     
===========================================
  Files           779      779             
  Lines         69439    69440      +1     
  Branches       9577     9577             
===========================================
+ Hits          40637    40639      +2     
+ Misses        25108    25107      -1     
  Partials       3694     3694             
Flag Coverage Δ *Carryforward flag
commons 96.37% <ø> (ø) Carriedforward from 8828d82
hstore 36.22% <ø> (+<0.01%) ⬆️ Carriedforward from 8828d82
pd 56.83% <ø> (ø) Carriedforward from 8828d82
server_hbase 42.48% <ø> (+<0.01%) ⬆️ Carriedforward from 8828d82
server_memory 56.66% <50.00%> (+<0.01%) ⬆️
server_rocksdb 42.97% <50.00%> (-0.04%) ⬇️
store 36.20% <ø> (ø) Carriedforward from 8828d82

*This pull request uses carry forward flags. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bitflicker64 bitflicker64 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking: no. Score: 9/10. Summary: extractRange() pushes only the first range into the backend query and keeps later ranges after a barrier as local steps, which fixes Invalid range and the wrong counts from #2216; the new VertexCoreTest and EdgeCoreTest cases fail on master and pass at this head on memory and RocksDB.

@imbajin imbajin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Score: 9.0/10 · Confidence: medium

Blocking: no

Summary

The first range is pushed down while later ranges remain local, preserving their stream-relative coordinates.

Evidence

Reviewed extractRange and both GraphStep and VertexStep callers. The added vertex and edge tests cover separated ranges. GitHub reports memory and RocksDB jobs successful.

Validation notes

I did not run the tests independently or exercise other storage backends.

@imbajin
imbajin merged commit 23840ec into apache:master Nov 19, 2026
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrectly range vertices/edges with barrier

3 participants