Skip to content

lightrag-memgraph: log GC-lag under-return in vector query()#228

Merged
antejavor merged 3 commits into
mainfrom
fix/vector-query-gc-lag-signal
Jul 17, 2026
Merged

lightrag-memgraph: log GC-lag under-return in vector query()#228
antejavor merged 3 commits into
mainfrom
fix/vector-query-gc-lag-signal

Conversation

@antejavor

@antejavor antejavor commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • MemgraphVectorStorage.query() silently dropped vector-search candidates whose backing node had already been deleted (e.g. by a concurrent, not-yet-committed transaction — Memgraph's native vector index runs at READ_UNCOMMITTED isolation by design, see the vector search docs), with no signal to callers that a shortfall could be caused by this rather than a genuine lack of matches.
  • The Cypher query now re-matches each raw hit by identity via OPTIONAL MATCH (instead of MATCH), so a candidate caught mid-delete comes back as a row with id IS NULL rather than being silently excluded, letting us count it.
  • query() now logs a warning with both the raw vector_search.search() hit count and the live-candidate count whenever they differ.
  • Documented the behavior (README + query() docstring) as expected READ_UNCOMMITTED behavior under concurrent deletes, not a general "GC lag" limitation.

Test plan

  • Existing vector integration tests still pass (test_vector_roundtrip_and_nearest_neighbour, test_vector_respects_threshold)
  • Added test_vector_query_logs_and_excludes_stale_candidates: deletes a node directly (bypassing store.delete(), which nulls the embedding first) to leave a stale vector-index entry, then asserts query() excludes it and logs the expected warning
  • Full suite (pytest tests/) passes against a live Memgraph instance: 19 passed
  • ruff check / ruff format --check pass

Fixes #225

Memgraph's vector index is garbage-collected on a delay after a node
delete, so vector_search.search() can hand back stale candidates for
already-deleted nodes. query() silently excluded these with no signal
that fewer than top_k live results were found. Now it logs a warning
with the raw hit count vs live count, and the README documents the
behavior as a known Memgraph limitation.

Fixes #225
…vior

Memgraph's vector index isn't garbage-collected on a delay -- per the
docs it operates at READ_UNCOMMITTED isolation, so stale candidates
surface specifically while a concurrent delete transaction is still
in flight and disappear once it commits. Reword the docstring, inline
comments, warning message, and README section accordingly.
@antejavor
antejavor merged commit af6adfe into main Jul 17, 2026
13 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.

lightrag-memgraph: vector query() silently drops dead candidates with no signal

1 participant