hold the lock in the second protect call

This commit is contained in:
vyzo 2022-01-31 19:21:03 +02:00
parent 5b9ea1b4e0
commit 877dfbe992

View File

@ -721,10 +721,13 @@ func (s *SplitStore) beginCriticalSection(markSet MarkSet) error {
} }
s.txnLk.Lock() s.txnLk.Lock()
s.txnMarkSet = markSet defer s.txnLk.Unlock()
s.txnLk.Unlock()
// and do it again to mark references that might have been created in the meantime s.txnMarkSet = markSet
// and do it again while holding the lock to mark references that might have been created
// in the meantime and avoid races of the type Has->txnRef->enterCS->Get fails because
// it's not in the markset
if err := s.protectTxnRefs(markSet); err != nil { if err := s.protectTxnRefs(markSet); err != nil {
return xerrors.Errorf("error protecting transactional references: %w", err) return xerrors.Errorf("error protecting transactional references: %w", err)
} }