Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

avoid data loss after restarting a container with a volum server

Konstantin Lebedev99ef280c7c8c
diff --git a/weed/storage/volume.go b/weed/storage/volume.go
index e0638d8a84..c6bf3e3292 100644
--- a/weed/storage/volume.go
+++ b/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()