-
Type: Task
-
Resolution: Unresolved
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
Context
There are various errors in the Go Driver that have Retryable() methods. These include
- WriteCommandError
- WriteConcernError
- poolClearedError
- retryableError
Currently there exists an interface called RetryablePoolError in the driver package for which all of these errors implement. However, it doesn't quite fit the context of any of the errors except poolClearedError.
It would be convenient for users to be able to check if an error is retryable at the mongo-package level. For example:
rerr, ok := err.(mongo.RetryableError) if ok && rerr.Retryable() { // do something knowing the error is retryable }
mongo.Retryable would look something like this:
type RetryableError interface {
Retryable() bool
}
Definition of done
We should answer the following questions before implementing:
1. Is it driver-appropriate to provide a way for users to determine if an error is retryable? I.e. is this something we should give an opinion on?
2. Is providing an interface the best solution. Could we instead check the retryablity internally and wrap the error in an error-implementing struct?
Pitfalls
It could be dangerous to add opinions on retryable errors in the stable API.
- is related to
-
GODRIVER-2191 Drivers should retry operations if connection handshake fails
- Blocked
-
GODRIVER-2579 Incorporate connection pool checkout into server selection loop
- Backlog