[CDRIVER-3070] Do not include lsid in commands if topology does not support sessions Created: 03/Apr/19  Updated: 27/Oct/23  Resolved: 07/Jul/20

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

Type: Bug Priority: Major - P3
Reporter: Jeremy Mikola Assignee: Roberto Sanchez
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on CDRIVER-3303 Some options not applied for OP_MSG w... Closed
Problem/Incident
Related
related to CDRIVER-3736 Exclusively depend on existence of lo... Closed
is related to JAVA-2811 Should not send lsid to a standalone Closed
is related to CDRIVER-2961 Support Retryable Writes on by Default Closed

 Description   

I came across this while researching test failures for CDRIVER-2961. In test_bulk_max_msg_size, the test suite builds a bulk write around the 48MB message size and I was originally accounting for the "txnNumber" (for retryWrites=true) based on whether a session ID was also being appended. I observed various test failures on standalone environments and ultimately observed that libmongoc was adding lsid to all outgoing commands sent with OP_MSG (unless sessions were unavailable due to lack of crypto). I was able to quickly observe this using APM in the PHP driver with libmongoc 1.13.0, although I expect this issue dates back to 1.9.0 when sessions were introduced.

Sending the session ID to the server on all commands only specifies that drivers MUST set the lsid field if a deployment supports sessions, but does not explicitly prohibit including lsid otherwise. Interestingly, standalone servers don't seem to complain about the field and likely ignore it.

While including the lsid is probably harmless, I'm not sure if we're missing a chance to raise a client-side error in the event the user is trying to specify an explicit session on an outgoing command and the topology does not support it.



 Comments   
Comment by Roberto Sanchez [ 07/Jul/20 ]

jmikola thanks for following up. I checked with Kevin and with his concurrence I am closing this issue.

Comment by Jeremy Mikola [ 07/Jul/20 ]

Based on resolved spec change for DRIVERS-1230, I think libmongoc is behaving correctly and this may not require any changes. If the standalone is reporting logicalSessionTimeoutMinutes, it does support sessions (obviously that doesn't extend to transactions, retryable writes).

Comment by Kevin Albertson [ 10/Aug/19 ]

Now that the sessions spec has spec tests, we should add a spec test to check this behavior. Created SPEC-1410.

Also, note that fixing this bug will reveal another bug in how options are applied to commands we send: CDRIVER-3303, so I'm making that a dependency.

Comment by Jeremy Mikola [ 03/Apr/19 ]

Looking into this a bit more, I believe libmongoc thinks the standalone supports sessions because its isMaster response includes logicalSessionTimeoutMinutes.

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