Skip to content

fix(graphlookup): make BFS traversal independent of shard row order - #5769

Merged
mengweieric merged 3 commits into
opensearch-project:mainfrom
mengweieric:menwe/graphlookup-order-independent-fix
Sep 18, 2026
Merged

mengweieric merged 3 commits into
opensearch-project:mainfrom
mengweieric:menwe/graphlookup-order-independent-fix

Conversation

@mengweieric

@mengweieric mengweieric commented Sep 14, 2026 •

Copy link
Copy Markdown
Collaborator

Description

graphLookup results currently depend on the order in which shards return documents, so the same query over the same data returns different result sets at different shard counts. Three coupled defects in the BFS enumerator:

  1. visitedNodes was mutated inside the per-row loop of a BFS level, so sibling rows within one level interfered with each other — and shards return rows within a level in arbitrary order.
  2. A document was emitted only if it still had unvisited onward edges (!nextValues.isEmpty()), silently dropping reached nodes whose edges all point to already-visited nodes.
  3. queryLookupTable pushed mustNot(visited) into the OpenSearch query, filtering reached documents out at the shard before the enumerator could emit them.

Why this is a product defect, not a test-side issue

A worked example using the graph_airports fixture:

JFK  connects [BOS, ORD]
BOS  connects [JFK, PWM]
ORD  connects [JFK]
PWM  connects [BOS, LHR]
LHR  connects [PWM]

Query: where airport='JFK' | graphLookup ... start=connects edge=connects-->airport. The level-0 frontier is {BOS, ORD}, so both the BOS and ORD documents are reached. What the old code returned depended on which one was processed first:

  • BOS first: BOS adds JFK, PWM to visitedNodes and is emitted. ORD's only edge (JFK) is now already visited, so ORD contributes no new frontier values and is silently dropped. Result omits ORD.
  • ORD first: ORD adds JFK and is emitted. BOS still contributes PWM and is emitted. Result contains both.

At 1 shard, Lucene returns rows in insertion order, so the same branch is taken every time and the output looks stable. At 5 shards, BOS and ORD live on different shards and arrival order varies per run, so the result set membership flips between runs.

This cannot be repaired in the tests:

  1. The assertions already use an order-insensitive matcher (rowsUnordered). What differs across runs is which rows exist (cardinality 1 vs 2), not their order.
  2. No expected-value change is correct. The stable single-shard output omits ORD, which is a direct neighbor of JFK (JFK.connects literally contains ORD). Encoding that as the oracle would assert a wrong answer; there is no expected value that matches a non-deterministic set.
  3. The design reference ([RFC] Implement a graphLookup command to demonstrate multi-hop queries #5088) models MongoDB $graphLookup, whose contract returns every reached document exactly once and leaves only array order unspecified. Non-deterministic membership is not a permitted reading, and the !nextValues.isEmpty() emission gate carries no design comment or documentation — it conflates "does this row extend the next frontier" with "should this row be emitted."

Fix

MongoDB $graphLookup all-reached semantics, per the design reference in #5088: the next frontier is computed against visitedNodes as of the start of each level and folded in only after the level completes; every matched document is emitted exactly once at its minimum depth; the shard-side visited filter is removed (termination still holds — a value enters the frontier at most once); deduplication keys on all projected columns instead of the connect-to value.

Known limitation (documented via an @Ignored executable spec): two distinct documents whose projected columns are byte-for-byte identical still collapse to one result; separating them requires projecting _id through the operator, left as follow-up.

The second commit gates CalcitePPLGraphLookupIT off the analytics-engine route: the parquet primary format rejects multi-valued fields, which the graph fixtures require.

Validation

  • CalcitePPLGraphLookupIT: green at 1 shard and 5 shards, both pushdown modes.
  • Full integTestRemote at 5 shards with this PR applied: 7,844 tests, 0 failures (two independent runs), plus a security-enabled (FGAC) cluster run: 0 failures.
  • Unit coverage: CalciteEnumerableGraphLookupTest drives the enumerator through configurable row orders and asserts identical result sets.

Related Issues

Design reference #5088.

Check List

  • New functionality includes testing
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@github-actions

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🧪 PR contains tests
🔒 No security concerns identified
✅ No TODO sections
🔀 No multiple PR themes
⚡ Recommended focus areas for review

Possible Issue

The identityKey method recursively canonicalizes nested structures but does not handle Map instances. If a row cell contains a Map (e.g., from a nested object field), two maps with identical key-value pairs but different iteration orders will produce unequal keys, causing duplicate emission of the same logical document. This manifests when the lookup table projects nested object fields and the shard returns them as maps.

private static Object identityKey(Object[] rowArray) {
  List<Object> key = new ArrayList<>(rowArray.length);
  for (Object cell : rowArray) {
    key.add(canonicalize(cell));
  }
  return key;
}

private static Object canonicalize(Object value) {
  if (value instanceof Object[] arr) {
    List<Object> list = new ArrayList<>(arr.length);
    for (Object item : arr) {
      list.add(canonicalize(item));
    }
    return list;
  }
  if (value instanceof List<?> list) {
    List<Object> canonical = new ArrayList<>(list.size());
    for (Object item : list) {
      canonical.add(canonicalize(item));
    }
    return canonical;
  }
  return value;
}

@github-actions

github-actions Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

PR Code Suggestions ✨

Latest suggestions up to bc65529

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Add null-safety to canonicalize method

The canonicalize method lacks null-safety checks. If value is null or if nested
collections contain null elements, the method will fail or produce inconsistent
keys. Add explicit null handling at the method entry and within the recursion to
ensure robust identity key generation for all document shapes.

opensearch/src/main/java/org/opensearch/sql/opensearch/storage/scan/CalciteEnumerableGraphLookup.java [621-637]

 private static Object canonicalize(Object value) {
+  if (value == null) {
+    return null;
+  }
   if (value instanceof Object[] arr) {
     List<Object> list = new ArrayList<>(arr.length);
     for (Object item : arr) {
       list.add(canonicalize(item));
     }
     return list;
   }
   if (value instanceof List<?> list) {
     List<Object> canonical = new ArrayList<>(list.size());
     for (Object item : list) {
       canonical.add(canonicalize(item));
     }
     return canonical;
   }
   return value;
 }
Suggestion importance[1-10]: 5

__

Why: Adding explicit null handling at the method entry improves robustness and makes the code's null-handling behavior more explicit. However, the recursive calls already handle null items correctly (they would be added as-is to the canonical list), so this is primarily a defensive programming improvement rather than a bug fix.

Low
Use LinkedHashSet for visitedNodes consistency

Consider using LinkedHashSet for visitedNodes to maintain insertion order
consistency with emitted and nextFrontier. While correctness doesn't depend on
visitedNodes order, using the same collection type across all three sets improves
code uniformity and makes the traversal behavior more predictable during debugging.

opensearch/src/main/java/org/opensearch/sql/opensearch/storage/scan/CalciteEnumerableGraphLookup.java [419-425]

-Set<Object> visitedNodes = new HashSet<>();
+Set<Object> visitedNodes = new LinkedHashSet<>();
 ...
 Set<Object> emitted = new HashSet<>();
Suggestion importance[1-10]: 3

__

Why: While using LinkedHashSet for visitedNodes would improve consistency with nextFrontier, it provides minimal practical benefit since visitedNodes is only used for membership testing. The suggestion correctly identifies that correctness doesn't depend on this change, making it a minor code style improvement.

Low

Previous suggestions

Suggestions up to commit 581538c
CategorySuggestion                                                                                                                                    Impact
Security
Add recursion depth limit to canonicalize

The recursive canonicalize method lacks depth protection, making it vulnerable to
stack overflow on deeply nested structures. Add a depth limit parameter to prevent
unbounded recursion, especially important since the method processes user-provided
document data that could be maliciously crafted.

opensearch/src/main/java/org/opensearch/sql/opensearch/storage/scan/CalciteEnumerableGraphLookup.java [621-637]

 private static Object canonicalize(Object value) {
+  return canonicalize(value, 0, 100);
+}
+
+private static Object canonicalize(Object value, int depth, int maxDepth) {
+  if (depth > maxDepth) {
+    throw new IllegalStateException("Canonicalization depth exceeded: " + maxDepth);
+  }
   if (value instanceof Object[] arr) {
     List<Object> list = new ArrayList<>(arr.length);
     for (Object item : arr) {
-      list.add(canonicalize(item));
+      list.add(canonicalize(item, depth + 1, maxDepth));
     }
     return list;
   }
   if (value instanceof List<?> list) {
     List<Object> canonical = new ArrayList<>(list.size());
     for (Object item : list) {
-      canonical.add(canonicalize(item));
+      canonical.add(canonicalize(item, depth + 1, maxDepth));
     }
     return canonical;
   }
   return value;
 }
Suggestion importance[1-10]: 7

__

Why: Valid security concern about unbounded recursion on deeply nested structures. The canonicalize method processes user-provided document data and could be vulnerable to stack overflow attacks with maliciously crafted deeply nested arrays. Adding a depth limit is a reasonable safeguard, though the specific limit of 100 might need adjustment based on expected use cases.

Medium
Possible issue
Halt traversal when result window exceeded

The warning is logged but the traversal continues, potentially producing incomplete
results without user awareness. Consider throwing an exception or adding a mechanism
to halt the traversal when the result window is exceeded, ensuring data integrity
and preventing silent partial results that could lead to incorrect graph analysis.

opensearch/src/main/java/org/opensearch/sql/opensearch/storage/scan/CalciteEnumerableGraphLookup.java [454-457]

 if (!graphLookup.usePIT
     && forwardResults.size() >= this.lookupScan.getOsIndex().getMaxResultWindow()) {
-  LOG.warn("BFS result size exceeds max result window, returning partial result.");
+  LOG.error("BFS result size exceeds max result window, halting traversal.");
+  throw new IllegalStateException(
+      "Graph traversal exceeded max result window. Consider using PIT or reducing maxDepth.");
 }
Suggestion importance[1-10]: 6

__

Why: The suggestion addresses a legitimate concern about silent partial results. However, throwing an exception might be too aggressive since the current behavior (logging a warning and continuing) could be intentional for graceful degradation. A better approach might be to make this configurable or document the behavior more clearly.

Low
General
Use LinkedHashSet for predictable traversal order

Consider using LinkedHashSet for both visitedNodes and emitted to maintain insertion
order. While the current implementation correctly ensures deterministic result sets,
using LinkedHashSet would make the traversal order more predictable for debugging
and testing, especially when dealing with converging paths or cycles.

opensearch/src/main/java/org/opensearch/sql/opensearch/storage/scan/CalciteEnumerableGraphLookup.java [419-425]

-Set<Object> visitedNodes = new HashSet<>();
+Set<Object> visitedNodes = new LinkedHashSet<>();
 ...
-Set<Object> emitted = new HashSet<>();
+Set<Object> emitted = new LinkedHashSet<>();
Suggestion importance[1-10]: 3

__

Why: The suggestion to use LinkedHashSet for visitedNodes is unnecessary since the order of visitedNodes doesn't affect the result set determinism (which is already guaranteed by the algorithm). The code already uses LinkedHashSet for nextFrontier (line 465) where order matters. Using LinkedHashSet for emitted would only add overhead without functional benefit since emission order is explicitly non-contractual.

Low
Suggestions up to commit 7823ca8
CategorySuggestion                                                                                                                                    Impact
Possible issue
Fail fast when result window exceeded

The warning is logged but the traversal continues with potentially incomplete
results, which could lead to incorrect graph traversal. Consider either throwing an
exception to fail fast, or implementing a mechanism to handle pagination when the
result window is exceeded, ensuring the BFS traversal remains complete and correct.

opensearch/src/main/java/org/opensearch/sql/opensearch/storage/scan/CalciteEnumerableGraphLookup.java [454-457]

 if (!graphLookup.usePIT
     && forwardResults.size() >= this.lookupScan.getOsIndex().getMaxResultWindow()) {
-  LOG.warn("BFS result size exceeds max result window, returning partial result.");
+  LOG.error("BFS result size exceeds max result window, cannot continue traversal.");
+  throw new IllegalStateException(
+      "Graph traversal exceeded max result window. Enable PIT or reduce maxDepth.");
 }
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly identifies that continuing traversal with incomplete results could lead to incorrect graph traversal. However, the existing warning allows graceful degradation, which may be intentional. Throwing an exception would be more correct but changes the error handling contract. The suggestion is valid but the severity depends on product requirements.

Medium
General
Handle nested maps in canonicalization

The canonicalize method doesn't handle nested maps or other complex objects that
might appear in document fields. If a document contains nested structures beyond
arrays/lists, the identity key could be incorrect, leading to false duplicates or
missed deduplication. Add handling for Map instances and consider deep
canonicalization of all nested structures.

opensearch/src/main/java/org/opensearch/sql/opensearch/storage/scan/CalciteEnumerableGraphLookup.java [621-637]

 private static Object canonicalize(Object value) {
   if (value instanceof Object[] arr) {
     List<Object> list = new ArrayList<>(arr.length);
     for (Object item : arr) {
       list.add(canonicalize(item));
     }
     return list;
   }
   if (value instanceof List<?> list) {
     List<Object> canonical = new ArrayList<>(list.size());
     for (Object item : list) {
       canonical.add(canonicalize(item));
     }
     return canonical;
   }
+  if (value instanceof Map<?, ?> map) {
+    Map<Object, Object> canonical = new HashMap<>();
+    for (Map.Entry<?, ?> entry : map.entrySet()) {
+      canonical.put(canonicalize(entry.getKey()), canonicalize(entry.getValue()));
+    }
+    return canonical;
+  }
   return value;
 }
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly identifies that canonicalize doesn't handle Map instances, which could appear in document fields. However, the current implementation handles the common cases (Object[] and List), and the residual limitation is already documented in the class-level comment. Adding Map support would improve robustness but isn't critical for the current use cases.

Low
Use LinkedHashSet for predictable traversal order

Consider using LinkedHashSet for both visitedNodes and emitted to maintain insertion
order. While the current implementation correctly ensures deterministic result sets,
using LinkedHashSet would make the traversal order more predictable for debugging
and testing, especially when dealing with converging paths or cycles.

opensearch/src/main/java/org/opensearch/sql/opensearch/storage/scan/CalciteEnumerableGraphLookup.java [419-425]

-Set<Object> visitedNodes = new HashSet<>();
+Set<Object> visitedNodes = new LinkedHashSet<>();
 ...
-Set<Object> emitted = new HashSet<>();
+Set<Object> emitted = new LinkedHashSet<>();
Suggestion importance[1-10]: 3

__

Why: While using LinkedHashSet for visitedNodes and emitted would maintain insertion order, the current HashSet implementation is sufficient for correctness. The PR already uses LinkedHashSet for nextFrontier where order matters. This suggestion offers marginal debugging benefits but doesn't address a functional issue.

Low
Suggestions up to commit af839fd
CategorySuggestion                                                                                                                                    Impact
Possible issue
Fail fast on result window overflow

The warning is logged but traversal continues, potentially leading to incomplete or
incorrect graph results. Consider either throwing an exception to fail fast, or
implementing proper pagination to handle large result sets. Silently returning
partial results could violate the all-reached semantics guarantee.

opensearch/src/main/java/org/opensearch/sql/opensearch/storage/scan/CalciteEnumerableGraphLookup.java [454-457]

 if (!graphLookup.usePIT
     && forwardResults.size() >= this.lookupScan.getOsIndex().getMaxResultWindow()) {
-  LOG.warn("BFS result size exceeds max result window, returning partial result.");
+  throw new IllegalStateException(
+      "BFS result size exceeds max result window. Enable PIT or reduce maxDepth.");
 }
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly identifies that silently returning partial results could violate the all-reached semantics. However, throwing an exception may be too aggressive for some use cases. The current warning is a reasonable compromise, but the suggestion to fail fast is valid for ensuring correctness.

Medium
General
Use LinkedHashSet for predictable ordering

Consider using LinkedHashSet instead of HashSet for visitedNodes and emitted to
maintain insertion order consistency. While the current implementation is correct,
using LinkedHashSet would make the traversal order more predictable for debugging
and testing purposes, especially when dealing with converging paths at the same
depth level.

opensearch/src/main/java/org/opensearch/sql/opensearch/storage/scan/CalciteEnumerableGraphLookup.java [419-425]

-Set<Object> visitedNodes = new HashSet<>();
+Set<Object> visitedNodes = new LinkedHashSet<>();
 ...
-Set<Object> emitted = new HashSet<>();
+Set<Object> emitted = new LinkedHashSet<>();
Suggestion importance[1-10]: 3

__

Why: While using LinkedHashSet would provide predictable ordering for debugging, the current HashSet implementation is correct and sufficient. The PR already uses LinkedHashSet for nextFrontier where order matters. For visitedNodes and emitted, only membership testing is needed, making HashSet appropriate.

Low

@codecov

codecov Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.92683% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.24%. Comparing base (8bfe96e) to head (bc65529).

Files with missing lines Patch % Lines
...rch/storage/scan/CalciteEnumerableGraphLookup.java 82.92% 4 Missing and 3 partials ⚠️

❌ Your project check has failed because the head coverage (63.24%) is below the target coverage (99.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5769      +/-   ##
============================================
+ Coverage     62.86%   63.24%   +0.38%     
- Complexity     8814     8820       +6     
============================================
  Files           938      938              
  Lines         40205    40209       +4     
  Branches       4528     4530       +2     
============================================
+ Hits          25275    25432     +157     
+ Misses        14125    13955     -170     
- Partials        805      822      +17     
Flag Coverage Δ
sql-engine 63.24% <82.92%> (+0.38%) ⬆️

Flags with carried forward coverage won't be shown. 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mengweieric mengweieric added testing Related to improving software testing bugFix labels Sep 14, 2026
@mengweieric
mengweieric force-pushed the menwe/graphlookup-order-independent-fix branch from 7823ca8 to 581538c Compare September 14, 2026 23:24
@mengweieric

Copy link
Copy Markdown
Collaborator Author

@qianheng-aws please take a look thanks

@qianheng-aws

Copy link
Copy Markdown
Collaborator
  1. A document was emitted only if it still had unvisited onward edges (!nextValues.isEmpty()), silently dropping reached nodes whose edges all point to already-visited nodes.
  2. queryLookupTable pushed mustNot(visited) into the OpenSearch query, filtering reached documents out at the shard before the enumerator could emit them.

In the original thoughts, that's implemented on purpose as some kinds of pruning optimization, which differs from MongoDB's behavior.

Designed as one of the graph-search engine of LightRAG, this graphlookup commands aims to retrieve all connected nodes but not all edges, since LightRAG has other logic of retrieving all edges, on the client side, based on all retrieved nodes. The silently dropped documents, i.e. edges, won't contribute to retrieving new nodes. That's why the code drops or filters them, in order to reduce the IO/CPU cost and get better performance.

@mengweieric I don't know the future direction of this command. If the above defeats you mentioned will block other feature development or the current behavior deviates our expectations, I think it makes sense to make these changes. But before merging, I think we should also re-run the benchmark in LightRAG here: HKUDS/LightRAG#2785.

.mustNot(getQueryBuilder(fromFieldIdx, visitedValues));
}

QueryBuilder query = getQueryBuilder(toFieldIdx, values);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

After removing "mustnot..." in the query, previously emitted documents can also exhaust the result window.

So, with usePIT=false, it will return less nodes than before.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

You are right that removing the exclusion can consume more of the result window when usePIT=false. That mode is already documented as best effort in this class, and the removed exclusion was filtering out documents that must be emitted, which is the membership bug this PR fixes. The usePIT=true path is unaffected since PIT paginates completely. Exact shard-side dedup would need _id projected into the scan row, which I can file as a follow-up issue if you think it is worth tightening the fast mode.

@mengweieric

Copy link
Copy Markdown
Collaborator Author

@qianheng-aws Thanks for the context on the pruning intent. The concern with the old behavior is that the pruning dropped reached documents non-deterministically under multi-shard layouts, so the same query on the same data could return different membership across runs, which affects the node set LightRAG consumes, not just the edge set.

On the benchmark, I ran a controlled A/B of this change directly: same cluster, same data and shard layout, only the plugin swapped, on a back-edge-heavy graph (6,804 edge docs, 5 shards, maxDepth=6, 30 timed runs per build, all counts stable):

Metric Before (with pruning) After (this PR)
median latency 139 ms 207 ms
p90 latency 160 ms 225 ms
reached documents returned 4,757 26,956
latency per returned document 0.029 ms 0.008 ms

The added time is the cost of returning documents the old code dropped, and per-document cost improved 3.8x. Workloads without edges into visited nodes see no cost delta.

The graph lookup enumerator produced different result sets depending on the
order shards returned rows within a BFS level, so the same query returned
different documents on a multi-shard index than on a single shard.

Three coupled causes:

- visitedNodes was mutated inside the per-row loop of a level, so one row
  changed what later rows in the same level were allowed to contribute.
- A matched document was emitted only when it still had unvisited onward
  edges, so a node whose edges point back to already-visited nodes was
  dropped, and whether that happened depended on the order above.
- queryLookupTable pushed a mustNot(visited) filter to the shard, so a
  reached document could be excluded before the enumerator saw it.

The next-level frontier is now computed against visitedNodes as of the start
of the level and folded in only after the level completes, which removes the
order dependence by construction. Every matched document is emitted once at
its minimum depth, decoupled from whether it has unvisited onward edges. The
mustNot(visited) pushdown is removed; traversal still terminates because a
value enters the frontier at most once, so each value is queried at most once.
Document identity is a structural key over all projected columns rather than
the connectTo value, so two distinct documents sharing a connectTo value are
no longer collapsed.

Tests are updated to the corrected result sets and use unordered matching
where the collected array order is genuinely non-contractual. A graph_multi
fixture is added. One test is retained @ignore'd as the executable
specification for the residual case of two documents whose projected columns
are identical but whose _id differs; separating those requires projecting _id
through deriveRowType, the planner rule and the enumerator.

Verified on a real cluster at both 1 and 5 primary shards: 34 tests, 0
failures in both layouts.

Signed-off-by: menwe <[email protected]>
The analytics-engine parquet primary format rejects multi-valued fields
(both graph_airports connects arrays and graph_multi mgr arrays fail
ingestion). Introduce a GRAPH_MULTI_VALUE_FIELD capability, gate
CalcitePPLGraphLookupIT on it at class level, and allowlist the graph
datasets in AnalyticsUnsupportedFieldStripVerifyIT.

Signed-off-by: menwe <[email protected]>
…tics

Covers the three traversal invariants of the order-independence fix without
a cluster, via an in-memory lookup scan that evaluates the pushed terms
query against fixed documents in a configurable return order:

- all-reached emission: every matched document is emitted exactly once at
  its minimum depth, including documents whose onward edges are all visited
- order independence: identical result sets for opposite row return orders,
  in forward and bidirectional traversal
- structural identity: distinct documents sharing a connectTo value are
  both kept; rediscovered documents deduplicate
- batch, normal, and literal start modes; null-edge terminals; maxDepth

Signed-off-by: menwe <[email protected]>
@mengweieric
mengweieric force-pushed the menwe/graphlookup-order-independent-fix branch from 581538c to bc65529 Compare September 17, 2026 22:31
@qianheng-aws

qianheng-aws commented Sep 18, 2026 •

Copy link
Copy Markdown
Collaborator

If our direction is for aligning with MongoDB's behavior and eliminate non-deterministic results, this PR LGTM.

so the same query on the same data could return different membership across runs, which affects the node set LightRAG consumes, not just the edge set.

I don't quite get this point. Per our historical test, it won't miss any nodes under the current implementation.

BOS first: BOS adds JFK, PWM to visitedNodes and is emitted. ORD's only edge (JFK) is now already visited, so ORD contributes no new frontier values and is silently dropped. Result omits ORD.

Take the case you described for example, although documents about ORD is omitted in the reachableAirports, the node of ORD is still always available in the value of connections field, which is the start node(s) of our graph search.

@mengweieric
mengweieric merged commit 12c26dc into opensearch-project:main Sep 18, 2026
42 of 43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugFix testing Related to improving software testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants