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]>
(cherry picked from commit 3f9effa)
  • Loading branch information
Ibrahim Jarif authored and NamanJain8 committed Mar 31, 2021
1 parent a79d379 commit b7d8d06
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 b7d8d06

Please sign in to comment.