Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an edge case where loading legacy backup revisions from pre-upgrade would result in the revision cache being in an inconsistent state and returning incorrect data for fetches. The fix ensures that legacy revisions without Clock Vector (CV) values have proper CV entries generated from their revision IDs when loaded into the cache.
Key changes:
- Enhanced revision cache loading to generate CV values for legacy revisions without existing CV data
- Added proper error handling for HLV map population during cache loading
- Improved cache consistency by ensuring both revision and CV lookup maps are properly populated
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| db/revision_cache_lru.go | Modified cache loading methods to generate CV from revID for legacy documents and added error handling for HLV map operations |
| db/revision_cache_test.go | Added comprehensive test to verify legacy revision loading and cache consistency |
torcolvin
left a comment
There was a problem hiding this comment.
LGTM, just some nits comments on scoping err to avoid escaping if we refactor and unique names of error messages if we ever see this in warning logs
| // check for memory based eviction | ||
| rc.revCacheMemoryBasedEviction(ctx) | ||
| rc.addToHLVMapPostLoad(docID, docRev.RevID, docRev.CV, collectionID) | ||
| err = rc.addToHLVMapPostLoad(docID, docRev.RevID, docRev.CV, collectionID) |
There was a problem hiding this comment.
| err = rc.addToHLVMapPostLoad(docID, docRev.RevID, docRev.CV, collectionID) | |
| err := rc.addToHLVMapPostLoad(docID, docRev.RevID, docRev.CV, collectionID) |
There was a problem hiding this comment.
I've intentionally not scoped the error here, essentially if we hit this code here the err is nil, and we if we error here and assign that error to err then below on line 224 we will enter the code block to remove the failed item form the cache altogether.
I will add comment to code explaining this so its clear.
CBG-4847
Pre-review checklist
fmt.Print,log.Print, ...)base.UD(docID),base.MD(dbName))docs/apiIntegration Tests
GSI=true,xattrs=truehttps://jenkins.sgwdev.com/job/SyncGatewayIntegration/75/