pkg/storage/ec: Make minor improvements in client.Repair (#2454)
* Fix some log message to actually report the number of pieces needed to repaired for reaching the successful/optimal threshold. * Remove some unneeded `nil` check conditional.
This commit is contained in:
parent
f275f2a0f9
commit
e0a8937c6c
@ -195,16 +195,10 @@ func (ec *ecClient) Repair(ctx context.Context, limits []*pb.AddressedOrderLimit
|
||||
}(i, addressedLimit)
|
||||
}
|
||||
|
||||
successfulNodes = make([]*pb.Node, len(limits))
|
||||
successfulHashes = make([]*pb.PieceHash, len(limits))
|
||||
ec.log.Sugar().Infof("Starting a timer for %s for repairing %s to %d nodes to reach at least the success threshold (%d nodes)...",
|
||||
timeout, path, nonNilCount(limits), rs.OptimalThreshold())
|
||||
|
||||
var successfulCount int32
|
||||
|
||||
// how many nodes must be repaired to reach the success threshold: o - (n - r)
|
||||
optimalCount := rs.OptimalThreshold() - (rs.TotalCount() - nonNilCount(limits))
|
||||
|
||||
ec.log.Sugar().Infof("Starting a timer for %s for repairing %s to %d nodes to reach the success threshold (%d nodes)...",
|
||||
timeout, path, optimalCount, rs.OptimalThreshold())
|
||||
|
||||
timer := time.AfterFunc(timeout, func() {
|
||||
if ctx.Err() != context.Canceled {
|
||||
ec.log.Sugar().Infof("Timer expired. Successfully repaired %s to %d nodes. Canceling the long tail...", path, atomic.LoadInt32(&successfulCount))
|
||||
@ -212,6 +206,9 @@ func (ec *ecClient) Repair(ctx context.Context, limits []*pb.AddressedOrderLimit
|
||||
}
|
||||
})
|
||||
|
||||
successfulNodes = make([]*pb.Node, len(limits))
|
||||
successfulHashes = make([]*pb.PieceHash, len(limits))
|
||||
|
||||
for range limits {
|
||||
info := <-infos
|
||||
|
||||
@ -232,11 +229,8 @@ func (ec *ecClient) Repair(ctx context.Context, limits []*pb.AddressedOrderLimit
|
||||
atomic.AddInt32(&successfulCount, 1)
|
||||
}
|
||||
|
||||
// Ensure timer is stopped in the case the success threshold is not reached
|
||||
// due to errors instead of slowness.
|
||||
if timer != nil {
|
||||
timer.Stop()
|
||||
}
|
||||
// Ensure timer is stopped
|
||||
_ = timer.Stop()
|
||||
|
||||
// TODO: clean up the partially uploaded segment's pieces
|
||||
defer func() {
|
||||
|
Loading…
Reference in New Issue
Block a user