close file in ScanVolumeFile()

fix https://github.com/chrislusf/seaweedfs/issues/761
This commit is contained in:
Chris Lu
2018-11-04 00:28:24 -07:00
parent 1fcbed4e90
commit f050b22d6c
3 changed files with 22 additions and 5 deletions

View File

@@ -44,7 +44,10 @@ func (v *Volume) commitCompact() error {
defer v.dataFileAccessLock.Unlock()
glog.V(3).Infof("Got volume %d committing lock...", v.Id)
v.nm.Close()
_ = v.dataFile.Close()
if err := v.dataFile.Close(); err != nil {
glog.V(0).Infof("fail to close volume %d", v.Id)
}
v.dataFile = nil
var e error
if e = v.makeupDiff(v.FileName()+".cpd", v.FileName()+".cpx", v.FileName()+".dat", v.FileName()+".idx"); e != nil {
@@ -60,10 +63,10 @@ func (v *Volume) commitCompact() error {
} else {
var e error
if e = os.Rename(v.FileName()+".cpd", v.FileName()+".dat"); e != nil {
return e
return fmt.Errorf("rename %s: %v", v.FileName()+".cpd", e)
}
if e = os.Rename(v.FileName()+".cpx", v.FileName()+".idx"); e != nil {
return e
return fmt.Errorf("rename %s: %v", v.FileName()+".cpx", e)
}
}