Skip to content

Commit

Permalink
pump/storage: Only hold the lock when collecting logFiles to scan
Browse files Browse the repository at this point in the history
  • Loading branch information
suzaku committed Jul 1, 2019
1 parent be47540 commit c3e7f0a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions pump/storage/vlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,18 +408,20 @@ func (vlog *valueLog) scanRequests(start valuePointer, fn func(*request) error)

// currently we only use this in NewAppend** to scan the record which not write to KV but in the value log, so it's OK to hold the vlog.filesLock lock
func (vlog *valueLog) scan(start valuePointer, fn func(vp valuePointer, record *Record) error) error {
vlog.filesLock.Lock()
defer vlog.filesLock.Unlock()

vlog.filesLock.RLock()
fids := vlog.sortedFids()

var lfs []*logFile
for _, fid := range fids {
if fid < start.Fid {
continue
if fid >= start.Fid {
lf := vlog.filesMap[fid]
lfs = append(lfs, lf)
}
lf := vlog.filesMap[fid]
}
vlog.filesLock.RUnlock()

for _, lf := range lfs {
var startOffset int64
if fid == start.Fid {
if lf.fid == start.Fid {
startOffset = start.Offset
}
err := lf.scan(startOffset, fn)
Expand Down

0 comments on commit c3e7f0a

Please sign in to comment.