scorch zap tighten up prepareSegment()'s lock area
This commit is contained in:
parent
6578655758
commit
3da191852d
|
@ -310,17 +310,21 @@ func (s *Scorch) prepareSegment(newSegment segment.Segment, ids []string,
|
||||||
introduction.persisted = make(chan error, 1)
|
introduction.persisted = make(chan error, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// get read lock, to optimistically prepare obsoleted info
|
// optimistically prepare obsoletes outside of rootLock
|
||||||
s.rootLock.RLock()
|
s.rootLock.RLock()
|
||||||
for _, seg := range s.root.segment {
|
root := s.root
|
||||||
|
root.AddRef()
|
||||||
|
s.rootLock.RUnlock()
|
||||||
|
|
||||||
|
for _, seg := range root.segment {
|
||||||
delta, err := seg.segment.DocNumbers(ids)
|
delta, err := seg.segment.DocNumbers(ids)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.rootLock.RUnlock()
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
introduction.obsoletes[seg.id] = delta
|
introduction.obsoletes[seg.id] = delta
|
||||||
}
|
}
|
||||||
s.rootLock.RUnlock()
|
|
||||||
|
_ = root.DecRef()
|
||||||
|
|
||||||
s.introductions <- introduction
|
s.introductions <- introduction
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue