Skip to content

cache: fix the index not being updated correctly on merge - #1611

Open
MichaelMure wants to merge 1 commit into
trunkfrom
fix-merge-index
Open

MichaelMure wants to merge 1 commit into
trunkfrom
fix-merge-index

Conversation

@MichaelMure

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI 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.

🟡 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 thread cache/subcache.go
Comment on lines +617 to +618
e := result.Entity.(EntityT)
cached := sc.makeCached(e, sc.entityUpdated)
Comment thread cache/subcache.go
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))
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.

2 participants