aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2021-07-13 01:29:57 -0700
committerChris Lu <chris.lu@gmail.com>2021-07-13 01:29:57 -0700
commit49c66e88a0144247533e88f2b99c4731bd67bf10 (patch)
treea75c27adff10cf7c37a6884bcafef68448ace614
parent01adc567aae3b03e09601c4db1b413be1e0c90bc (diff)
downloadseaweedfs-49c66e88a0144247533e88f2b99c4731bd67bf10.tar.xz
seaweedfs-49c66e88a0144247533e88f2b99c4731bd67bf10.zip
volume: change all writes to fsync during graceful stopping
fix https://github.com/chrislusf/seaweedfs/issues/2193
-rw-r--r--weed/command/volume.go1
-rw-r--r--weed/server/volume_server.go5
-rw-r--r--weed/storage/store.go7
3 files changed, 12 insertions, 1 deletions
diff --git a/weed/command/volume.go b/weed/command/volume.go
index 38a52efee..712fa0dce 100644
--- a/weed/command/volume.go
+++ b/weed/command/volume.go
@@ -259,6 +259,7 @@ func (v VolumeServerOptions) startVolumeServer(volumeFolders, maxVolumeCounts, v
// Stop heartbeats
if !volumeServer.StopHeartbeat() {
+ volumeServer.SetStopping()
glog.V(0).Infof("stop send heartbeat and wait %d seconds until shutdown ...", *v.preStopSeconds)
time.Sleep(time.Duration(*v.preStopSeconds) * time.Second)
}
diff --git a/weed/server/volume_server.go b/weed/server/volume_server.go
index be50739c6..3bf740dc0 100644
--- a/weed/server/volume_server.go
+++ b/weed/server/volume_server.go
@@ -112,6 +112,11 @@ func NewVolumeServer(adminMux, publicMux *http.ServeMux, ip string,
return vs
}
+func (vs *VolumeServer) SetStopping() {
+ glog.V(0).Infoln("Stopping volume server...")
+ vs.store.SetStopping()
+}
+
func (vs *VolumeServer) Shutdown() {
glog.V(0).Infoln("Shutting down volume server...")
vs.store.Close()
diff --git a/weed/storage/store.go b/weed/storage/store.go
index 6ff996a3c..cda1e196b 100644
--- a/weed/storage/store.go
+++ b/weed/storage/store.go
@@ -46,6 +46,7 @@ type Store struct {
DeletedVolumesChan chan master_pb.VolumeShortInformationMessage
NewEcShardsChan chan master_pb.VolumeEcShardInformationMessage
DeletedEcShardsChan chan master_pb.VolumeEcShardInformationMessage
+ isStopping bool
}
func (s *Store) String() (str string) {
@@ -321,6 +322,10 @@ func (s *Store) CollectHeartbeat() *master_pb.Heartbeat {
}
+func (s *Store) SetStopping() {
+ s.isStopping = true
+}
+
func (s *Store) Close() {
for _, location := range s.Locations {
location.Close()
@@ -333,7 +338,7 @@ func (s *Store) WriteVolumeNeedle(i needle.VolumeId, n *needle.Needle, fsync boo
err = fmt.Errorf("volume %d is read only", i)
return
}
- _, _, isUnchanged, err = v.writeNeedle2(n, fsync)
+ _, _, isUnchanged, err = v.writeNeedle2(n, fsync && s.isStopping)
return
}
glog.V(0).Infoln("volume", i, "not found!")