aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2022-08-22 14:12:23 -0700
committerchrislu <chris.lu@gmail.com>2022-08-22 14:12:23 -0700
commit676e27c589a99691ba78f010a067898d89f764ac (patch)
treecee659e16990e035b0f7a3c2ed994f1ea77cf9c2
parent601ba5fb680eb028080160c857feda9b7044ab56 (diff)
downloadseaweedfs-676e27c589a99691ba78f010a067898d89f764ac.tar.xz
seaweedfs-676e27c589a99691ba78f010a067898d89f764ac.zip
shell: stop long running jobs if lock is lost
-rw-r--r--weed/shell/command_ec_common.go4
-rw-r--r--weed/shell/command_ec_decode.go5
-rw-r--r--weed/shell/command_ec_encode.go4
-rw-r--r--weed/shell/command_ec_rebuild.go4
-rw-r--r--weed/shell/command_volume_balance.go4
-rw-r--r--weed/shell/command_volume_fix_replication.go4
-rw-r--r--weed/shell/command_volume_tier_move.go4
7 files changed, 29 insertions, 0 deletions
diff --git a/weed/shell/command_ec_common.go b/weed/shell/command_ec_common.go
index 5af783d04..0335e7e26 100644
--- a/weed/shell/command_ec_common.go
+++ b/weed/shell/command_ec_common.go
@@ -18,6 +18,10 @@ import (
func moveMountedShardToEcNode(commandEnv *CommandEnv, existingLocation *EcNode, collection string, vid needle.VolumeId, shardId erasure_coding.ShardId, destinationEcNode *EcNode, applyBalancing bool) (err error) {
+ if !commandEnv.isLocked() {
+ return fmt.Errorf("lock is lost")
+ }
+
copiedShardIds := []uint32{uint32(shardId)}
if applyBalancing {
diff --git a/weed/shell/command_ec_decode.go b/weed/shell/command_ec_decode.go
index aebc20579..4c92d1a2f 100644
--- a/weed/shell/command_ec_decode.go
+++ b/weed/shell/command_ec_decode.go
@@ -89,6 +89,11 @@ func (c *commandEcDecode) Do(args []string, commandEnv *CommandEnv, writer io.Wr
}
func doEcDecode(commandEnv *CommandEnv, topoInfo *master_pb.TopologyInfo, collection string, vid needle.VolumeId) (err error) {
+
+ if !commandEnv.isLocked() {
+ return fmt.Errorf("lock is lost")
+ }
+
// find volume location
nodeToEcIndexBits := collectEcNodeShardBits(topoInfo, vid)
diff --git a/weed/shell/command_ec_encode.go b/weed/shell/command_ec_encode.go
index 7834ba1fe..a023686dc 100644
--- a/weed/shell/command_ec_encode.go
+++ b/weed/shell/command_ec_encode.go
@@ -93,6 +93,10 @@ func (c *commandEcEncode) Do(args []string, commandEnv *CommandEnv, writer io.Wr
}
func doEcEncode(commandEnv *CommandEnv, collection string, vid needle.VolumeId, parallelCopy bool) (err error) {
+ if !commandEnv.isLocked() {
+ return fmt.Errorf("lock is lost")
+ }
+
// find volume location
locations, found := commandEnv.MasterClient.GetLocations(uint32(vid))
if !found && len(locations) > 0 {
diff --git a/weed/shell/command_ec_rebuild.go b/weed/shell/command_ec_rebuild.go
index 486b94059..4b2952793 100644
--- a/weed/shell/command_ec_rebuild.go
+++ b/weed/shell/command_ec_rebuild.go
@@ -131,6 +131,10 @@ func rebuildEcVolumes(commandEnv *CommandEnv, allEcNodes []*EcNode, collection s
func rebuildOneEcVolume(commandEnv *CommandEnv, rebuilder *EcNode, collection string, volumeId needle.VolumeId, locations EcShardLocations, writer io.Writer, applyChanges bool) error {
+ if !commandEnv.isLocked() {
+ return fmt.Errorf("lock is lost")
+ }
+
fmt.Printf("rebuildOneEcVolume %s %d\n", collection, volumeId)
// collect shard files to rebuilder local disk
diff --git a/weed/shell/command_volume_balance.go b/weed/shell/command_volume_balance.go
index 2cfe0337c..6ba376d2c 100644
--- a/weed/shell/command_volume_balance.go
+++ b/weed/shell/command_volume_balance.go
@@ -306,6 +306,10 @@ func attemptToMoveOneVolume(commandEnv *CommandEnv, volumeReplicas map[uint32][]
func maybeMoveOneVolume(commandEnv *CommandEnv, volumeReplicas map[uint32][]*VolumeReplica, fullNode *Node, candidateVolume *master_pb.VolumeInformationMessage, emptyNode *Node, applyChange bool) (hasMoved bool, err error) {
+ if !commandEnv.isLocked() {
+ return false, fmt.Errorf("lock is lost")
+ }
+
if candidateVolume.ReplicaPlacement > 0 {
replicaPlacement, _ := super_block.NewReplicaPlacementFromByte(byte(candidateVolume.ReplicaPlacement))
if !isGoodMove(replicaPlacement, volumeReplicas[candidateVolume.Id], fullNode, emptyNode) {
diff --git a/weed/shell/command_volume_fix_replication.go b/weed/shell/command_volume_fix_replication.go
index 247627839..5cc4ba645 100644
--- a/weed/shell/command_volume_fix_replication.go
+++ b/weed/shell/command_volume_fix_replication.go
@@ -104,6 +104,10 @@ func (c *commandVolumeFixReplication) Do(args []string, commandEnv *CommandEnv,
}
}
+ if !commandEnv.isLocked() {
+ return fmt.Errorf("lock is lost")
+ }
+
if len(overReplicatedVolumeIds) > 0 {
if err := c.deleteOneVolume(commandEnv, writer, takeAction, overReplicatedVolumeIds, volumeReplicas, allLocations, pickOneReplicaToDelete); err != nil {
return err
diff --git a/weed/shell/command_volume_tier_move.go b/weed/shell/command_volume_tier_move.go
index 352b322a7..978d53751 100644
--- a/weed/shell/command_volume_tier_move.go
+++ b/weed/shell/command_volume_tier_move.go
@@ -222,6 +222,10 @@ func (c *commandVolumeTierMove) doVolumeTierMove(commandEnv *CommandEnv, writer
func (c *commandVolumeTierMove) doMoveOneVolume(commandEnv *CommandEnv, writer io.Writer, vid needle.VolumeId, toDiskType types.DiskType, locations []wdclient.Location, sourceVolumeServer pb.ServerAddress, dst location, ioBytePerSecond int64) (err error) {
+ if !commandEnv.isLocked() {
+ return fmt.Errorf("lock is lost")
+ }
+
// mark all replicas as read only
if err = markVolumeReplicasWritable(commandEnv.option.GrpcDialOption, vid, locations, false); err != nil {
return fmt.Errorf("mark volume %d as readonly on %s: %v", vid, locations[0].Url, err)