fix race in protectView
This commit is contained in:
parent
1900c907fd
commit
ee63be26a1
@ -494,7 +494,7 @@ func (s *SplitStore) View(ctx context.Context, cid cid.Cid, cb func([]byte) erro
|
||||
}
|
||||
|
||||
// critical section
|
||||
s.txnLk.RLock()
|
||||
s.txnLk.RLock() // the lock is released in protectView if we are not in critical section
|
||||
if s.txnMarkSet != nil {
|
||||
has, err := s.txnMarkSet.Has(cid)
|
||||
s.txnLk.RUnlock()
|
||||
@ -509,7 +509,6 @@ func (s *SplitStore) View(ctx context.Context, cid cid.Cid, cb func([]byte) erro
|
||||
|
||||
return s.cold.View(ctx, cid, cb)
|
||||
}
|
||||
s.txnLk.RUnlock()
|
||||
|
||||
// views are (optimistically) protected two-fold:
|
||||
// - if there is an active transaction, then the reference is protected.
|
||||
|
@ -156,7 +156,7 @@ func (s *SplitStore) protectTipSets(apply []*types.TipSet) {
|
||||
|
||||
// transactionally protect a view
|
||||
func (s *SplitStore) protectView(c cid.Cid) {
|
||||
s.txnLk.RLock()
|
||||
// the txnLk is held for read
|
||||
defer s.txnLk.RUnlock()
|
||||
|
||||
if s.txnActive {
|
||||
|
Loading…
Reference in New Issue
Block a user