fix: skip 75ms retry when store is empty (Bug 2)#582
Merged
rwmjhb merged 1 commit intoCortexReach:masterfrom Apr 12, 2026
Merged
fix: skip 75ms retry when store is empty (Bug 2)#582rwmjhb merged 1 commit intoCortexReach:masterfrom
rwmjhb merged 1 commit intoCortexReach:masterfrom
Conversation
Empty store: no write-ahead lag to wait for, so skip the retry sleep entirely. countRows() is O(1) metadata op — negligible cost. Logic: if results.length === 0 AND store.count() === 0 → return empty immediately, no sleep. Fixes Bug 2 from community code audit.
This was referenced Apr 12, 2026
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.
Bug 2: 75ms retry on empty results
Reported in community code audit
Problem
In
retrieveWithRetry()(tools.ts), when the first retrieval returns 0 results, it always sleeps 75ms and retries — even when the store is completely empty. This 75ms is pure wasted latency on a cold/empty store.Fix
Added
count()method toMemoryStoreusing LanceDB'scountRows()(O(1) metadata operation).retrieveWithRetrynow accepts an optionalcountStorecallback — if the store has 0 rows, the retry is skipped entirely.Testing
countStoreis optional, all 5 existing call sites still workFiles changed
src/store.ts: +6 lines (count()method)src/tools.ts: +11/-5 lines (optional param + guard + 5 call sites)Audit reference: memory-lancedb-pro code audit — Bug 2, reported 2026-04-11