Skip to content

Commit

Permalink
fixed/manipmongo: do not check deadline for context in retry
Browse files Browse the repository at this point in the history
primalmotion committed Aug 26, 2019
1 parent 80b5160 commit 82ba361
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions manipmongo/helpers.go
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@
package manipmongo

import (
"context"
"fmt"
"strconv"
"strings"
@@ -231,12 +230,14 @@ func RunQuery(mctx manipulate.Context, operationFunc func() (interface{}, error)
}
}

deadline, ok := mctx.Context().Deadline()
if ok && deadline.Before(time.Now()) {
return nil, manipulate.NewErrCannotExecuteQuery(context.DeadlineExceeded.Error())
select {
case <-mctx.Context().Done():
return nil, manipulate.NewErrCannotExecuteQuery(mctx.Context().Err().Error())
default:
}

<-time.After(backoff.Next(try, deadline))
deadline, _ := mctx.Context().Deadline()
time.Sleep(backoff.Next(try, deadline))
try++
}
}

0 comments on commit 82ba361

Please sign in to comment.