mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-11-03 10:37:35 +01:00
check for nil needle map before compaction sync
When CommitCompact runs concurrently, it sets v.nm = nil under dataFileAccessLock. CompactByIndex does not hold that lock, so v.nm.Sync() can hit a nil pointer. Add an early nil check to return an error instead of crashing. Fixes #8591
This commit is contained in:
1 parent
d4d2e511ed
commit
889ae7d22d
1 file changed
+3
@@ -117,6 +117,9 @@ func (v *Volume) CompactByIndex(opts *CompactOptions) error {
|
||||
if v.DataBackend == nil {
|
||||
return fmt.Errorf("volume %d backend is empty remote:%v", v.Id, v.HasRemoteFile())
|
||||
}
|
||||
if v.nm == nil {
|
||||
return fmt.Errorf("volume %d needle map is nil", v.Id)
|
||||
}
|
||||
if err := v.DataBackend.Sync(); err != nil {
|
||||
glog.V(0).Infof("compact2 failed to sync volume dat %d: %v", v.Id, err)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user