mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
volume: ensure the volume dat and idx files are always closed
fix https://github.com/chrislusf/seaweedfs/issues/1646
This commit is contained in:
parent
cc839f935d
commit
d171d9f988
|
@ -25,6 +25,20 @@ func loadVolumeWithoutIndex(dirname string, collection string, id needle.VolumeI
|
|||
func (v *Volume) load(alsoLoadIndex bool, createDatIfMissing bool, needleMapKind NeedleMapType, preallocate int64) (err error) {
|
||||
alreadyHasSuperBlock := false
|
||||
|
||||
hasLoadedVolume := false
|
||||
defer func() {
|
||||
if !hasLoadedVolume {
|
||||
if v.nm != nil {
|
||||
v.nm.Close()
|
||||
v.nm = nil
|
||||
}
|
||||
if v.DataBackend != nil {
|
||||
v.DataBackend.Close()
|
||||
v.DataBackend = nil
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
hasVolumeInfoFile := v.maybeLoadVolumeInfo() && v.volumeInfo.Version != 0
|
||||
|
||||
if v.HasRemoteFile() {
|
||||
|
@ -151,5 +165,9 @@ func (v *Volume) load(alsoLoadIndex bool, createDatIfMissing bool, needleMapKind
|
|||
|
||||
stats.VolumeServerVolumeCounter.WithLabelValues(v.Collection, "volume").Inc()
|
||||
|
||||
if err == nil {
|
||||
hasLoadedVolume = true
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue