diff --git a/weed/plugin/worker/ec_repair_handler.go b/weed/plugin/worker/ec_repair_handler.go index b764fb5f9..ab7d33ad5 100644 --- a/weed/plugin/worker/ec_repair_handler.go +++ b/weed/plugin/worker/ec_repair_handler.go @@ -20,6 +20,8 @@ import ( "google.golang.org/protobuf/proto" ) +const recentTaskWindowSize = 10 + type ecRepairWorkerConfig struct { MinIntervalSeconds int } @@ -410,8 +412,13 @@ func (h *EcRepairHandler) rebuildMissingShards(ctx context.Context, plan *ecrepa }); err != nil { return nil, err } -if len(rebuilt) == 0 && len(plan.MissingShards) > 0 { - return nil, fmt.Errorf("rebuild shards for volume %d completed but returned no rebuilt shard IDs", plan.VolumeID) + if len(rebuilt) == 0 { + if len(plan.MissingShards) > 0 { + glog.V(1).Infof("EC Repair: resp.RebuiltShardIds empty; assuming all missing shards rebuilt for volume %d (%d shards)", plan.VolumeID, len(plan.MissingShards)) + } else { + glog.V(1).Infof("EC Repair: resp.RebuiltShardIds empty for volume %d with no missing shards declared", plan.VolumeID) + } + rebuilt = append(rebuilt, plan.MissingShards...) } return rebuilt, nil } @@ -562,7 +569,7 @@ func (h *EcRepairHandler) fetchTopology(ctx context.Context, masterAddresses []s if response == nil || response.TopologyInfo == nil { continue } - activeTopology := topology.NewActiveTopology(10) + activeTopology := topology.NewActiveTopology(recentTaskWindowSize) if err := activeTopology.UpdateTopology(response.TopologyInfo); err != nil { return nil, nil, err } diff --git a/weed/worker/tasks/ec_repair/plan.go b/weed/worker/tasks/ec_repair/plan.go index 8ee1435ba..8e648d7fb 100644 --- a/weed/worker/tasks/ec_repair/plan.go +++ b/weed/worker/tasks/ec_repair/plan.go @@ -56,7 +56,7 @@ func Detect(topoInfo *master_pb.TopologyInfo, collectionFilter string, maxResult var candidates []*RepairCandidate hasMore := false - for _, key := range keys { + for idx, key := range keys { state := states[key] if state == nil { continue @@ -80,9 +80,7 @@ func Detect(topoInfo *master_pb.TopologyInfo, collectionFilter string, maxResult }) if maxResults > 0 && len(candidates) >= maxResults { - if len(candidates) < len(keys) { - hasMore = true - } + hasMore = idx < len(keys)-1 break } }