-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: None
-
None
Currently it's possible for a WithTransaction call to return an error when the context is canceled or times out that does not indicate that the error is related to the context expiring.
Consider the context "done" check in WithTransaction here. If the context expires while handling an error unrelated to context expiration (e.g. a transient server error), the returned error will not indicate that WithTransaction returned due to the context expiring. That is potentially confusing to users because the error returned from WithTransaction doesn't always specify why WithTransaction stopped retrying.
The spec for Convenient Transactions does specify using a maximum timeout of 120 seconds and requires that drivers return the original error if that timeout is reached without completing the transaction. However, the spec doesn't include any analog for Go's context-based cancellation or timeout, so the Go driver just uses the same error handling logic as the WithTransaction 120 second max timeout.
Update WithTransaction to either return the context error (e.g. context.Canceled or context.DeadlineExceeded) or the original error wrapped by the context error.
Note that this is an alternative to GODRIVER-2468.
- related to
-
GODRIVER-2468 Don't check Context expiration in WithTransaction
- Closed