[CDRIVER-3333] Session is not pinned when only a single mongos is present Created: 23/Aug/19  Updated: 27/Oct/23  Resolved: 26/Aug/19

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: 1.15.0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Andreas Braun Assignee: Unassigned
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related

 Description   

When running a sharded transaction in a sharded cluster with a single mongos node, the session is not pinned to that server. Since topology scans may reveal additional mongos nodes, this can cause issues later. The session needs to be pinned even when running with a single mongos node.

I've also added a SPEC ticket to clarify this in the transaction spec: SPEC-1428.



 Comments   
Comment by Andreas Braun [ 26/Aug/19 ]

As per my comment in the PR, I'm closing this as "Works as Designed". Since the initial topology type is set to "Single" if only a single mongos was found in the connection string or via SRV discovery and this disables polling for additional members, I don't see why a session should be pinned in this instance.

Comment by Kevin Albertson [ 23/Aug/19 ]

Commented in the PR discussion. I validated with the same manual tests that if we enter SRV polling because the topology type is sharded, we stay in sharded even if the host list reduces to one host during polling.

Comment by Jeremy Mikola [ 23/Aug/19 ]

Per kevin.albertson's response in mongodb/mongo-php-driver#1014, I think this can be resolved "Works as Designed". In summary: when the URI includes only a single host (and no replSet option), libmongoc initializes the topology type to single. Session pinning is only done for sharded topology types.

Kevin also clarified that if the initial topology type is sharded (i.e. connection string includes multiple mongos hosts), but SRV polling reduces the list of known mongos hosts down to one, the topology type will remain sharded and pinning will still occur. That is relevant since SRV polling could later pick up additional mongos hosts and a pinned session would be quite relevant.

kevin.albertson: Do you want to leave this issue open to double-check the above? You did say "IIUC" in the comment so we should probably make sure if there's any doubt.

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