-
Notifications
You must be signed in to change notification settings - Fork 140
CBG-4879: fix for data race when invalidating cache for local wins #7778
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a data race in the revision cache when invalidating cache entries for documents that result from local wins in conflict resolution. Instead of removing the entire cache entry, it now only removes the CV (current version) map entry to prevent race conditions between read and write operations on the cache.
- Adds a new
RemoveCVOnly
method to selectively remove CV lookup entries without affecting revID lookups - Enhances eviction logic to handle scenarios where multiple cache entries share the same CV but have different revision IDs
- Updates the change cache to use the new selective removal method for local wins
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
db/revision_cache_interface.go | Adds the RemoveCVOnly method to the RevisionCache interface and collection wrapper |
db/revision_cache_lru.go | Implements RemoveCVOnly method and updates eviction logic to handle CV/revID mismatches |
db/revision_cache_bypass.go | Adds no-op implementation of RemoveCVOnly for bypass cache |
db/change_cache.go | Updates DocChanged to use RemoveCVOnly instead of RemoveWithCV for local wins |
db/revision_cache_test.go | Adds tests to verify race condition fix and proper eviction behavior |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM just +1'd copilots suggestion
CBG-4879
Pre-review checklist
fmt.Print
,log.Print
, ...)base.UD(docID)
,base.MD(dbName)
)docs/api
Dependencies (if applicable)
Integration Tests
GSI=true,xattrs=true
https://jenkins.sgwdev.com/job/SyncGatewayIntegration/99/