From 6cea23d091120f53b7a6b2dd657add0954d93739 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 4 Jun 2019 01:32:36 -0700 Subject: [PATCH] purge duplicated ec shards --- weed/shell/command_ec_balance.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/weed/shell/command_ec_balance.go b/weed/shell/command_ec_balance.go index 664284df9..414f0ec4d 100644 --- a/weed/shell/command_ec_balance.go +++ b/weed/shell/command_ec_balance.go @@ -186,18 +186,20 @@ func doDeduplicateEcShards(ctx context.Context, commandEnv *commandEnv, collecti continue } sortEcNodes(ecNodes) - fmt.Printf("ec shard %d.%d has %d copies, removing from %+v\n", vid, shardId, len(ecNodes), ecNodes[1:]) + fmt.Printf("ec shard %d.%d has %d copies, keeping %v\n", vid, shardId, len(ecNodes), ecNodes[0].info.Id) if !applyBalancing { continue } + + duplicatedShardIds := []uint32{uint32(shardId)} for _, ecNode := range ecNodes[1:] { - duplicatedShardIds := []uint32{uint32(shardId)} if err := unmountEcShards(ctx, commandEnv.option.GrpcDialOption, vid, ecNode.info.Id, duplicatedShardIds); err != nil { return err } if err := sourceServerDeleteEcShards(ctx, commandEnv.option.GrpcDialOption, collection, vid, ecNode.info.Id, duplicatedShardIds); err != nil { return err } + ecNode.freeEcSlot++ } } return nil