[CDRIVER-4718] Transactions executed on a load balancer do not specify a recoveryToken Created: 05/Sep/23  Updated: 28/Oct/23  Resolved: 17/Oct/23

Status: Closed
Project: C Driver
Component/s: Transactions
Affects Version/s: None
Fix Version/s: 1.25.0, 1.24.5

Type: Bug Priority: Unknown
Reporter: Jeremy Mikola Assignee: Kevin Albertson
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to PHPLIB-1228 Permit legacy transaction tests to ru... Closed
is related to DRIVERS-2713 Permit legacy transaction tests to ru... Implementing

 Description   

Summary

By design, libmongoc does not pin sessions for transactions executed against a load balanced topology. This is because clients are pooled instead of connections, and each client only maintains a single socket per server (one for the case of a load balancer).

Although the rules for pinning in load balancer mode may not apply, rules for the recoveryToken field should apply to both sharded and load balanced topologies. When connected to a load balancer, libmongoc does not appear to ever send a recoveryToken field in outgoing commitTransaction or abortTransaction commands. This was observed when testing the PHP driver with legacy transaction spec tests, which were recently modified to add "load-balanced" to the list of supported topologies for runOn requirements (DRIVERS-2713).

According to kevin.albertson@mongodb.com, libmongoc's current behavior is:

  • recoveryToken is sent if it was previously stored.
  • Storing recoveryToken requires _in_sharded_txn() be true.
  • being true requires topology type MONGOC_TOPOLOGY_SHARDED (not MONGOC_TOPOLOGY_LOAD_BALANCED)

This may be indicative of a bug.



 Comments   
Comment by Githook User [ 17/Oct/23 ]

Author:

{'name': 'Kevin Albertson', 'email': 'kevin.albertson@mongodb.com', 'username': 'kevinAlbs'}

Message: CDRIVER-4718 store `recoveryToken` for Load Balanced topology (#1417)

  • add regression test
  • format mongoc-cluster.c
  • store recoveryToken for loadBalanced topology
  • make `_in_sharded_txn` static
  • use `static`

Co-authored-by: Kyle Kloberdanz <kyle.kloberdanz@mongodb.com>

  • removing redundant calls to `_mongoc_topology_get_type`

Co-authored-by: Kyle Kloberdanz <kyle.kloberdanz@mongodb.com>
Branch: r1.24
https://github.com/mongodb/mongo-c-driver/commit/3fec27d07e9903edf7fdd4b12849e7afa1de9fe6

Comment by Githook User [ 17/Oct/23 ]

Author:

{'name': 'Kevin Albertson', 'email': 'kevin.albertson@mongodb.com', 'username': 'kevinAlbs'}

Message: CDRIVER-4718 store `recoveryToken` for Load Balanced topology (#1417)

  • add regression test
  • format mongoc-cluster.c
  • store recoveryToken for loadBalanced topology
  • make `_in_sharded_txn` static
  • use `static`

Co-authored-by: Kyle Kloberdanz <kyle.kloberdanz@mongodb.com>

  • removing redundant calls to `_mongoc_topology_get_type`

Co-authored-by: Kyle Kloberdanz <kyle.kloberdanz@mongodb.com>
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/b39e2ebedc65fac7c28f935e12a83df32ac30adf

Generated at Wed Feb 07 21:21:44 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.