storagenode/orders: Don't return error Archiving unsent (#2903)
Don't return error when archiving errors which aren't found in the DB
because it causes Storage Node send orders cycle to stop.
This was applied in the commit e47b8ed131
but the last call to orders.Archive function was missed so the errors
weren't returned when not found orders in the first call but they were
returned in the second call.
This commit address the second call for making handleBatches function
never returns error on not found orders.
This commit is contained in:
parent
243d280591
commit
537769d7fa
@ -204,12 +204,7 @@ func (service *Service) handleBatches(ctx context.Context, requests chan Archive
|
||||
|
||||
buffer := make([]ArchiveRequest, 0, cap(requests))
|
||||
|
||||
for request := range requests {
|
||||
buffer = append(buffer, request)
|
||||
if len(buffer) < cap(buffer) {
|
||||
continue
|
||||
}
|
||||
|
||||
archive := func(ctx context.Context, archivedAt time.Time, requests ...ArchiveRequest) error {
|
||||
if err := service.orders.Archive(ctx, time.Now().UTC(), buffer...); err != nil {
|
||||
if !OrderNotFoundError.Has(err) {
|
||||
return err
|
||||
@ -217,12 +212,26 @@ func (service *Service) handleBatches(ctx context.Context, requests chan Archive
|
||||
|
||||
service.log.Warn("some unsent order aren't in the DB", zap.Error(err))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
for request := range requests {
|
||||
buffer = append(buffer, request)
|
||||
if len(buffer) < cap(buffer) {
|
||||
continue
|
||||
}
|
||||
|
||||
if err := archive(ctx, time.Now().UTC(), buffer...); err != nil {
|
||||
return err
|
||||
}
|
||||
buffer = buffer[:0]
|
||||
}
|
||||
|
||||
if len(buffer) > 0 {
|
||||
return service.orders.Archive(ctx, time.Now().UTC(), buffer...)
|
||||
return archive(ctx, time.Now().UTC(), buffer...)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user