make view protection optimistic again, as there is a race window

This commit is contained in:
vyzo 2021-07-09 15:41:10 +03:00
parent da0feb3fa4
commit 095d7427ba

View File

@ -432,9 +432,7 @@ func (s *SplitStore) View(cid cid.Cid, cb func([]byte) error) error {
return cb(data) return cb(data)
} }
err := s.hot.View(cid, // views are (optimistically) protected two-fold:
func(data []byte) error {
// views are protected two-fold:
// - if there is an active transaction, then the reference is protected. // - if there is an active transaction, then the reference is protected.
// - if there is no active transaction, active views are tracked in a // - if there is no active transaction, active views are tracked in a
// wait group and compaction is inhibited from starting until they // wait group and compaction is inhibited from starting until they
@ -447,9 +445,7 @@ func (s *SplitStore) View(cid cid.Cid, cb func([]byte) error) error {
defer wg.Done() defer wg.Done()
} }
return cb(data) err := s.hot.View(cid, cb)
})
switch err { switch err {
case bstore.ErrNotFound: case bstore.ErrNotFound:
if s.debug != nil { if s.debug != nil {