make view protection optimistic again, as there is a race window
This commit is contained in:
parent
da0feb3fa4
commit
095d7427ba
@ -432,24 +432,20 @@ 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 {
|
// - if there is an active transaction, then the reference is protected.
|
||||||
// views are protected two-fold:
|
// - if there is no active transaction, active views are tracked in a
|
||||||
// - if there is an active transaction, then the reference is protected.
|
// wait group and compaction is inhibited from starting until they
|
||||||
// - if there is no active transaction, active views are tracked in a
|
// have all completed. this is necessary to ensure that a (very) long-running
|
||||||
// wait group and compaction is inhibited from starting until they
|
// view can't have its data pointer deleted, which would be catastrophic.
|
||||||
// have all completed. this is necessary to ensure that a (very) long-running
|
// Note that we can't just RLock for the duration of the view, as this could
|
||||||
// view can't have its data pointer deleted, which would be catastrophic.
|
// lead to deadlock with recursive views.
|
||||||
// Note that we can't just RLock for the duration of the view, as this could
|
wg := s.protectView(cid)
|
||||||
// lead to deadlock with recursive views.
|
if wg != nil {
|
||||||
wg := s.protectView(cid)
|
defer wg.Done()
|
||||||
if wg != nil {
|
}
|
||||||
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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user