cache: fix the index not being updated correctly on merge - #1611
Open
MichaelMure wants to merge 1 commit into
Open
MichaelMure wants to merge 1 commit into
MichaelMure wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical and moderate cache/index consistency issues remain.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Fixes full-text index updates when entities are merged into the cache and adds regression coverage.
Changes:
- Index newly merged and updated entities.
- Test searchability and index completeness after merges.
File summaries
| File | Summary and final findings |
|---|---|
cache/subcache.go |
Updates indexes during merges. Critical (2 votes): concurrent DAG merges may index stale entity data. Moderate (2 votes): indexing failures can leave cache and index state inconsistent. |
cache/repo_cache_test.go |
Adds merge-index regression tests. Nit (1 vote): the restart behavior test does not close and reopen cacheB. |
Review details
Suppressed comments (1)
cache/repo_cache_test.go:341
- The comment claims this verifies restart behavior, but the test never closes and reopens cacheB; it only reads the same index handle. Reopen the cache before these assertions so the test covers persisted cache/index consistency and the Load count check, rather than only the in-process index.
// the index of B is complete, so a restart doesn't need to rebuild it
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+617
to
+618
| e := result.Entity.(EntityT) | ||
| cached := sc.makeCached(e, sc.entityUpdated) |
Comment on lines
+620
to
+627
| sc.mu.Lock() | ||
| sc.excerpts[result.Id] = sc.makeExcerpt(cached) | ||
| // might as well keep them in memory | ||
| sc.cached[result.Id] = cached | ||
| sc.mu.Unlock() | ||
|
|
||
| // index before notifying, so that an observer can already search it | ||
| return index.IndexOne(result.Id.String(), sc.makeIndexData(cached)) |
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.
No description provided.