Browse Source

Merge pull request #2104 from kmlebedev/sync_volume_on_close

avoid data loss after restarting a container with a volum server
pull/2112/head
Chris Lu 4 years ago
committed by GitHub
parent
commit
62142ff1d2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      weed/storage/volume.go

6
weed/storage/volume.go

@ -180,10 +180,16 @@ func (v *Volume) Close() {
v.dataFileAccessLock.Lock()
defer v.dataFileAccessLock.Unlock()
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 = 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 = nil
stats.VolumeServerVolumeCounter.WithLabelValues(v.Collection, "volume").Dec()

Loading…
Cancel
Save