satellite/repair: use mutex instead of channel to collect download errors
Change-Id: I3f958e9cc95126a25f73ccd105e614b51089edc5
This commit is contained in:
parent
077ec96d94
commit
dc69e1b16e
@ -84,7 +84,9 @@ func (ec *ECRepairer) Get(ctx context.Context, limits []*pb.AddressedOrderLimit,
|
||||
|
||||
limiter := sync2.NewLimiter(es.RequiredCount())
|
||||
cond := sync.NewCond(&sync.Mutex{})
|
||||
errChan := make(chan error, len(limits))
|
||||
|
||||
var errlist errs.Group
|
||||
var mu sync.Mutex
|
||||
|
||||
for currentLimitIndex, limit := range limits {
|
||||
if limit == nil {
|
||||
@ -147,7 +149,9 @@ func (ec *ECRepairer) Get(ctx context.Context, limits []*pb.AddressedOrderLimit,
|
||||
ec.log.Debug("Failed to download pieces for repair",
|
||||
zap.Error(err))
|
||||
}
|
||||
errChan <- fmt.Errorf("node id: %s, error: %w", limit.GetLimit().StorageNodeId.String(), err)
|
||||
mu.Lock()
|
||||
errlist.Add(fmt.Errorf("node id: %s, error: %w", limit.GetLimit().StorageNodeId.String(), err))
|
||||
mu.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
@ -160,16 +164,9 @@ func (ec *ECRepairer) Get(ctx context.Context, limits []*pb.AddressedOrderLimit,
|
||||
}
|
||||
|
||||
limiter.Wait()
|
||||
close(errChan)
|
||||
|
||||
var errlist errs.Group
|
||||
if successfulPieces < es.RequiredCount() {
|
||||
mon.Meter("download_failed_not_enough_pieces_repair").Mark(1) //mon:locked
|
||||
for err := range errChan {
|
||||
if err != nil {
|
||||
errlist.Add(err)
|
||||
}
|
||||
}
|
||||
return nil, failedPieces, &irreparableError{
|
||||
piecesAvailable: int32(successfulPieces),
|
||||
piecesRequired: int32(es.RequiredCount()),
|
||||
|
Loading…
Reference in New Issue
Block a user