[GODRIVER-2672] Comprehensively checking for transaction error labels is not possible Created: 05/Dec/22  Updated: 28/Oct/23  Resolved: 31/Mar/23

Status: Closed
Project: Go Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 1.11.4

Type: Bug Priority: Major - P3
Reporter: Divjot Arora (Inactive) Assignee: Qingyang Hu
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on GODRIVER-2579 Incorporate connection pool checkout ... Backlog
Duplicate
is duplicated by GODRIVER-2673 Add the "TransientTransactionError" l... Closed
Related
Documentation Changes: Not Needed
Documentation Changes Summary:

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?


 Description   

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



 Comments   
Comment by Githook User [ 04/Apr/23 ]

Author:

{'name': 'Qingyang Hu', 'email': '103950869+qingyang-hu@users.noreply.github.com', 'username': 'qingyang-hu'}

Message: GODRIVER-2672 Return ServerError with "TransientTransactionError" label for server selection timeouts. (#1198)
Branch: release/1.11
https://github.com/mongodb/mongo-go-driver/commit/0351e7faf70f94078fde218e5262dfcccbeaa9c8

Comment by Githook User [ 31/Mar/23 ]

Author:

{'name': 'Qingyang Hu', 'email': '103950869+qingyang-hu@users.noreply.github.com', 'username': 'qingyang-hu'}

Message: GODRIVER-2672 Return ServerError with "TransientTransactionError" label for server selection timeouts. (#1198)
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/623520655eaf5f9961a92d266fd0ecaa73f42f96

Comment by Matt Dale [ 05/Dec/22 ]

This may be significantly simpler to implement once GODRIVER-2579 is done.

Generated at Thu Feb 08 08:39:07 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.