Skip to content

Commit

Permalink
fix(postingList): Acquire lock before reading the cached posting list (
Browse files Browse the repository at this point in the history
…#7632)

The GetNew function may fetch the posting list from the cache. This
cached copy of the posting list might be still in use at other places
and so we need to acquire a lock on it before we read it.

Co-authored-by: NamanJain8 <[email protected]>
  • Loading branch information
Ibrahim Jarif and NamanJain8 authored Mar 30, 2021
1 parent 1f84a52 commit 3f9effa
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions posting/mvcc.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,12 +437,14 @@ func getNew(key []byte, pstore *badger.DB, readTs uint64) (*List, error) {
key: key,
plist: l.plist,
}
l.RLock()
if l.mutationMap != nil {
lCopy.mutationMap = make(map[uint64]*pb.PostingList, len(l.mutationMap))
for ts, pl := range l.mutationMap {
lCopy.mutationMap[ts] = proto.Clone(pl).(*pb.PostingList)
}
}
l.RUnlock()
return lCopy, nil
}
}
Expand Down

0 comments on commit 3f9effa

Please sign in to comment.