Fix retry error missed (#10318)

Signed-off-by: godchen <qingxiang.chen@zilliz.com>
This commit is contained in:
godchen 2021-10-21 12:20:35 +08:00 committed by GitHub
parent f68a3358dd
commit cfe2546b0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -32,15 +32,18 @@ func Do(ctx context.Context, fn func() error, opts ...Option) error {
for i := uint(0); i < c.attempts; i++ {
if err := fn(); err != nil {
if ok := IsUncoverable(err); ok {
return err
}
el = append(el, err)
if ok := IsUncoverable(err); ok {
return el
}
select {
case <-time.After(c.sleep):
case <-ctx.Done():
return ctx.Err()
el = append(el, ctx.Err())
return el
}
c.sleep *= 2