aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2022-02-16 09:11:34 -0800
committerchrislu <chris.lu@gmail.com>2022-02-16 09:11:34 -0800
commita129bda7d98bdbd8ca41c3aeb94739582686a6f1 (patch)
tree023020d98dd70a9521e200704bcbf370103d760f
parent118d0e01a8aadf5e52f87412bd2db3e7a0e31839 (diff)
downloadseaweedfs-a129bda7d98bdbd8ca41c3aeb94739582686a6f1.tar.xz
seaweedfs-a129bda7d98bdbd8ca41c3aeb94739582686a6f1.zip
sync data first before stopping
-rw-r--r--weed/storage/disk_location.go10
-rw-r--r--weed/storage/store.go3
-rw-r--r--weed/storage/volume.go15
3 files changed, 28 insertions, 0 deletions
diff --git a/weed/storage/disk_location.go b/weed/storage/disk_location.go
index af4ec1eb4..d618db296 100644
--- a/weed/storage/disk_location.go
+++ b/weed/storage/disk_location.go
@@ -317,6 +317,16 @@ func (l *DiskLocation) VolumesLen() int {
return len(l.volumes)
}
+func (l *DiskLocation) SetStopping() {
+ l.volumesLock.Lock()
+ for _, v := range l.volumes {
+ v.SetStopping()
+ }
+ l.volumesLock.Unlock()
+
+ return
+}
+
func (l *DiskLocation) Close() {
l.volumesLock.Lock()
for _, v := range l.volumes {
diff --git a/weed/storage/store.go b/weed/storage/store.go
index 8381705d6..30fe63b63 100644
--- a/weed/storage/store.go
+++ b/weed/storage/store.go
@@ -327,6 +327,9 @@ func (s *Store) CollectHeartbeat() *master_pb.Heartbeat {
func (s *Store) SetStopping() {
s.isStopping = true
+ for _, location := range s.Locations {
+ location.SetStopping()
+ }
}
func (s *Store) Close() {
diff --git a/weed/storage/volume.go b/weed/storage/volume.go
index c6bf3e329..14bc5f22d 100644
--- a/weed/storage/volume.go
+++ b/weed/storage/volume.go
@@ -175,6 +175,21 @@ func (v *Volume) DiskType() types.DiskType {
return v.location.DiskType
}
+func (v *Volume) SetStopping() {
+ v.dataFileAccessLock.Lock()
+ defer v.dataFileAccessLock.Unlock()
+ if v.nm != nil {
+ if err := v.nm.Sync(); err != nil {
+ glog.Warningf("Volume SetStopping fail to sync volume idx %d", v.Id)
+ }
+ }
+ if v.DataBackend != nil {
+ if err := v.DataBackend.Sync(); err != nil {
+ glog.Warningf("Volume SetStopping fail to sync volume %d", v.Id)
+ }
+ }
+}
+
// Close cleanly shuts down this volume
func (v *Volume) Close() {
v.dataFileAccessLock.Lock()