Fix panic in FileStore.walkKeys

If a TSM file is replaced while walkKeys is running, a panic could
occur because the mmap has been unmapped.
pull/9748/head
Jason Wilder 2018-04-30 17:01:49 -06:00
parent ede6b2f041
commit ec3f5c353c
1 changed files with 6 additions and 0 deletions

View File

@ -311,6 +311,12 @@ func (f *FileStore) WalkKeys(seek []byte, fn func(key []byte, typ byte) error) e
return nil
}
// Ensure files are not unmapped while we're iterating over them.
for _, r := range f.files {
r.Ref()
defer r.Unref()
}
ki := newMergeKeyIterator(f.files, seek)
f.mu.RUnlock()
for ki.Next() {