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
- Join all errors together that happen during Operation.Execute retries if the final attempt doesn't succeed. Return the joined error.
- Join all errors that happen during WithTransaction retries if the final attempt doesn't succeed.
- Join all errors that happen during ChangeStream.executeOperation retries if the final attempt doesn't succeed.
Don't use the "internal/errutil" package because it's unnecessary now that the min Go version is 1.25. We will remove that package completely with GODRIVER-4063.
Open questions:
- What happens if unified spec test assertions fail? Can we resolve them by making sure error assertions use errors.Is or errors.As?
Pitfalls
- We've never joined errors together. It's possible there will be unexpected error handling bugs introduced by returning joined errors.
- is related to
-
GODRIVER-4063 Remove the internal/errutil pkg after bumping the min Go version to 1.20+
-
- Backlog
-
-
GODRIVER-4172 Maintain the error chain when returning a mongo.WriteException
-
- Needs Triage
-