diff options
| author | 2026-02-21 19:51:40 +0800 | |
|---|---|---|
| committer | 2026-02-21 19:51:40 +0800 | |
| commit | 8600b32050fa21d63baf4b21e75f8fc71fcfc610 (patch) | |
| tree | a644258ef08b89b0593095fdeabd0c37d757d414 /objectstore/packed/idx_open.go | |
| parent | objectstore/packed: Separate idx candidate lookup vs actually opening it (diff) | |
| signature | No signature | |
objectstore/packed: Optimize pack candidate lookup and locking
Diffstat (limited to 'objectstore/packed/idx_open.go')
| -rw-r--r-- | objectstore/packed/idx_open.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/objectstore/packed/idx_open.go b/objectstore/packed/idx_open.go index 45f0f83d..c00a7bac 100644 --- a/objectstore/packed/idx_open.go +++ b/objectstore/packed/idx_open.go @@ -40,34 +40,34 @@ type idxFile struct { // candidateForPack returns one discovered candidate for a pack basename. func (store *Store) candidateForPack(packName string) (packCandidate, bool) { - store.stateMu.RLock() + store.candidatesMu.RLock() candidate, ok := store.candidateByPack[packName] - store.stateMu.RUnlock() + store.candidatesMu.RUnlock() return candidate, ok } // openIndex returns one opened and parsed index, caching it by pack basename. func (store *Store) openIndex(candidate packCandidate) (*idxFile, error) { - store.stateMu.RLock() + store.idxMu.RLock() if index, ok := store.idxByPack[candidate.packName]; ok { - store.stateMu.RUnlock() + store.idxMu.RUnlock() return index, nil } - store.stateMu.RUnlock() + store.idxMu.RUnlock() index, err := openIdxFile(store.root, candidate.idxName, candidate.packName, store.algo) if err != nil { return nil, err } - store.stateMu.Lock() + store.idxMu.Lock() if existing, ok := store.idxByPack[candidate.packName]; ok { - store.stateMu.Unlock() + store.idxMu.Unlock() _ = index.close() return existing, nil } store.idxByPack[candidate.packName] = index - store.stateMu.Unlock() + store.idxMu.Unlock() return index, nil } |
