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

Comprehensively checking for transaction error labels is not possible

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.11.4
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Not Needed
    • 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?

      Summary

      Per the transactions spec:

      Any command error that includes the "TransientTransactionError" error label in the "errorLabels" field. Any network error or server selection error encountered running any command besides commitTransaction in a transaction. In the case of command errors, the server adds the label; in the case of network errors or server selection errors where the client receives no server reply, the client adds the label.

      Drivers add the "UnknownTransactionCommitResult" to a server selection error from commitTransaction, even if this is the first attempt to send commitTransaction. It is true in this case that the driver knows the result: the transaction is definitely not committed. However, the "UnknownTransactionCommitResult" label properly communicates to the application that calling commitTransaction again may succeed.

      The Go Driver does not explicitly add these labels to server selection timeouts or provide an easy way for an application to check that a given error has these labels. Currently, the only function exposed for checking error labels is mongo.ServerError#HasErrorLabel, but that doesn't work for this case as server selection errors are not covered by the mongo.ServerError interface.

      The only workaround for applications is to manually check for *topology.ServerSelectionError, which is not ideal given that this type is under the "x" API.

      Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).

      This issue is present in v1.11.0, which is the latest released version at the time of writing. It can be reproduced against any server version/topology that supports transactions (4.0+ replicasets, 4.2+ sharded clusters).

      How to Reproduce

      Spin up a single node replicaset on localhost:27017 with any MongoDB version 4.0 or higher and run this example code. Note that the code explicitly shuts down the server, so the node must be restarted before each invocation.

      Additional Background

            Assignee:
            qingyang.hu@mongodb.com Qingyang Hu
            Reporter:
            divjot.arora@mongodb.com Divjot Arora (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: