mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-10-21 07:17:25 +08:00
avoid data loss after restarting a container with a volum server
This commit is contained in:
@@ -180,10 +180,16 @@ func (v *Volume) Close() {
|
|||||||
v.dataFileAccessLock.Lock()
|
v.dataFileAccessLock.Lock()
|
||||||
defer v.dataFileAccessLock.Unlock()
|
defer v.dataFileAccessLock.Unlock()
|
||||||
if v.nm != nil {
|
if v.nm != nil {
|
||||||
|
if err := v.nm.Sync(); err != nil {
|
||||||
|
glog.Warningf("Volume Close fail to sync volume idx %d", v.Id)
|
||||||
|
}
|
||||||
v.nm.Close()
|
v.nm.Close()
|
||||||
v.nm = nil
|
v.nm = nil
|
||||||
}
|
}
|
||||||
if v.DataBackend != nil {
|
if v.DataBackend != nil {
|
||||||
|
if err := v.DataBackend.Sync(); err != nil {
|
||||||
|
glog.Warningf("Volume Close fail to sync volume %d", v.Id)
|
||||||
|
}
|
||||||
_ = v.DataBackend.Close()
|
_ = v.DataBackend.Close()
|
||||||
v.DataBackend = nil
|
v.DataBackend = nil
|
||||||
stats.VolumeServerVolumeCounter.WithLabelValues(v.Collection, "volume").Dec()
|
stats.VolumeServerVolumeCounter.WithLabelValues(v.Collection, "volume").Dec()
|
||||||
|
Reference in New Issue
Block a user