Ensure ECClient upload timer is stopped when no more status is expected (#1397)
This change ensures that the upload timer of ECClient is always stopped after no more status is expected from uploaded pieces. It also ensures that the "Timer expired" message will be logged only if the context is not already cancelled. This is to avoid confusing logs where a "Timer expired" message is logged significantly later and mixes with similar messages logged from the upload of the next file segments.
This commit is contained in:
parent
5f57d2c906
commit
5fa7a4a7c6
@ -119,8 +119,10 @@ func (ec *ecClient) Put(ctx context.Context, nodes []*pb.Node, rs eestream.Redun
|
||||
rs.RepairThreshold(), elapsed.Seconds(), more.Seconds(), rs.OptimalThreshold())
|
||||
|
||||
timer = time.AfterFunc(more, func() {
|
||||
zap.S().Infof("Timer expired. Successfully uploaded to %d nodes. Canceling the long tail...", atomic.LoadInt32(&successfulCount))
|
||||
cancel()
|
||||
if ctx.Err() != context.Canceled {
|
||||
zap.S().Infof("Timer expired. Successfully uploaded to %d nodes. Canceling the long tail...", atomic.LoadInt32(&successfulCount))
|
||||
cancel()
|
||||
}
|
||||
})
|
||||
case rs.OptimalThreshold():
|
||||
zap.S().Infof("Success threshold (%d nodes) reached. Canceling the long tail...", rs.OptimalThreshold())
|
||||
@ -130,6 +132,12 @@ func (ec *ecClient) Put(ctx context.Context, nodes []*pb.Node, rs eestream.Redun
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure timer is stopped in the case of repair threshold is reached, but
|
||||
// not the success threshold due to errors instead of slowness.
|
||||
if timer != nil {
|
||||
timer.Stop()
|
||||
}
|
||||
|
||||
/* clean up the partially uploaded segment's pieces */
|
||||
defer func() {
|
||||
select {
|
||||
|
Loading…
Reference in New Issue
Block a user