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.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
shell: stop long running jobs if lock is lost
chrislu676e27c589a9
diff --git a/weed/shell/command_ec_common.go b/weed/shell/command_ec_common.goindex 5af783d04f..0335e7e269 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.goindex aebc205793..4c92d1a2fa 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 locationnodeToEcIndexBits := collectEcNodeShardBits(topoInfo, vid)diff --git a/weed/shell/command_ec_encode.go b/weed/shell/command_ec_encode.goindex 7834ba1fe7..a023686dc5 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 locationlocations, 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.goindex 486b94059d..4b29527934 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 sfunc 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 diskdiff --git a/weed/shell/command_volume_balance.go b/weed/shell/command_volume_balance.goindex 2cfe0337c7..6ba376d2cc 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.goindex 247627839c..5cc4ba6451 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 errdiff --git a/weed/shell/command_volume_tier_move.go b/weed/shell/command_volume_tier_move.goindex 352b322a7b..978d53751c 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, writerfunc (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 onlyif 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)