Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-2467

Return a Context error if WithTransaction exited due to Context expiration

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • 2.1.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      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.

            Assignee:
            Unassigned Unassigned
            Reporter:
            matt.dale@mongodb.com Matt Dale
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: