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) (#7671)

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)

Co-authored-by: Ibrahim Jarif <[email protected]>
  • Loading branch information
NamanJain8 and Ibrahim Jarif authored May 5, 2021
1 parent b0aa797 commit e87a295
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 e87a295

Please sign in to comment.