-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Not Needed
-
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
- depends on
-
GODRIVER-2579 Incorporate connection pool checkout into server selection loop
- Backlog
- is duplicated by
-
GODRIVER-2673 Add the "TransientTransactionError" label when server selection fails during a transaction
- Closed