[CDRIVER-4110] Session causalConsistency option should not default to true if snapshot is true Created: 29/Jul/21  Updated: 28/Oct/23  Resolved: 04/Aug/21

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

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

Issue Links:
Depends
is depended on by PHPC-1761 Snapshot Reads Closed
Related
is related to CDRIVER-4034 Snapshot reads on Secondaries Closed
is related to DRIVERS-1607 Spec: Snapshot reads on Secondaries Closed
Epic Link: Snapshot reads on Secondaries
Backwards Compatibility: Fully Compatible

 Description   

CDRIVER-4034 included a workaround to explicitly set causalConsistency to false if snapshot was true when constructing a session entity in a unified test. This could potentially override an explicit value for causalConsistency if a test were to specify both as true.

Note: no such test exists because it would require expecting a failure when constructing the session entity (before any test operations are run). This could only be done through a valid-fail test in the unified test format spec, which currently isn't use for testing other specifications. In this case, the conflict between both session options is covered by a prose test.

Having said that, the Causal Consistency spec was changed as part of Snapshot Sessions to not default to true if snapshot was explicitly set to true. Fixing this should entail changes to the session options API and entail reverting the above work-around in the test runner.



 Comments   
Comment by Jeremy Mikola [ 04/Aug/21 ]

I don't believe there is any BC concern here as there is no behavioral change without using the new snapshot option – and even then, this fix just ensures that users don't inadvertently get a client-side error when only specifying snapshot=true.

Comment by Githook User [ 04/Aug/21 ]

Author:

{'name': 'Jeremy Mikola', 'email': 'jmikola@gmail.com', 'username': 'jmikola'}

Message: CDRIVER-4110: Default for causal_consistency depends on snapshot (#838)

  • Don't force casualConsistency=false when creating session with snapshot=true

This was originally added in d5f73e18eac7acaa05f31c4ffde68c9cd565704a

  • Relocate session snapshot prose test

This prose test is defined in the sessions spec, not transactions. It also does not require the server to support transactions.

  • Default for causal_consistency depends on snapshot

Use mongoc_optional_t for causal_consistency and snapshot session opts to track whether or not values have been set.

This also removes explicitly setting causal_consistency to true in _mongoc_client_session_new, since mongoc_session_opts_get_causal_consistency now enforces the default value.
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/230369cd070d800545b0c91fd47e1537a50ce6ca

Comment by Jeremy Mikola [ 30/Jul/21 ]

https://github.com/mongodb/mongo-c-driver/pull/838

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