-
Type:
Sub-task
-
Resolution: Unresolved
-
Priority:
Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
None
-
Go Drivers
-
Not Needed
-
None
-
None
-
None
-
None
-
None
-
None
Context
Currently, there's a bunch of logic that tries to pick which error to return after a failed retry. That logic frequently discards important error information and makes it difficult or impossible to troubleshoot problems without a bunch of additional event monitoring or logging enabled. It would be much more useful to collect all error information for all operation attempts and return them in one error, painting a much more complete picture of the history of a given operation in a single error value. To do that, we should use errors.Join to join all errors that happen while attempting a given operation together.
Definition of done
- Return an error where the error message describes all retries that were attempted before eventually failing. Implement for Operation.Execute, WithTransaction, and ChangeStream.executeOperation.
- Implement a new type, errutil.RetryError, that takes the "main" error and a list of all retry attempt errors. It should wrap only the "main" error, only including the retry attempt errors in the error message.
- "Main" error means the error that is currently returned. In some cases, the Retryable Writes spec says we should return a different error than the chronologically final error (e.g. when the final error is labeled with "NoWritesPerformed" and the previous error had an indefinite outcome). We should only unwrap to that main error, not any of the other retry errors. Hence, only implement Unwrap() error on errutil.RetryError, not Unwrap() []error.