[CDRIVER-2439] Cluster time should not be gossipped to a standalone Created: 21/Dec/17  Updated: 28/Oct/23  Resolved: 30/Apr/18

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

Type: Bug Priority: Minor - P4
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:
Related
Epic Link: Post-3.6 cleanup

 Description   

In SPEC-1015, I discussed a scenario whereby I witnessed libmongoc append $clusterTime to an outgoing command to a 3.6 standalone server:

While implementing the eleventh causal consistency spec test for PHPC, I found an odd behavior in libmongoc. The test plan states:

11. When connected to a deployment that does not support cluster times messages sent to the server should not include $clusterTime

  • skip this test when connected to a deployment that does support cluster times
  • document = collection.findOne({})
  • capture the command sent to the server
  • assert that the command does not include a $clusterTime field

As-is, this test uses an implicit client session. If we connect to a standalone (any version) or a replica set or shard cluster (pre-3.6), we will not see the driver add $clusterTime to an outgoing command document. This is because the client session itself has no cluster time, nor does the driver's client object (isMaster would not have reported a cluster time).

After implementing the test as-is, I then modified it to use an explicit client session. I then manually advanced the cluster time of that client session. When running the modified test against a 3.6 standalone, I witnessed libmongoc append $clusterTime to the outgoing command document. The 3.6 standalone seemed to happily ignore the extra field.

I believe this was due to libmongoc only checking if cluster time is non-NULL and OP_MSG is being used in mongoc_cmd_parts_assemble(). Depending on the outcome of SPEC-1015, I think it would be correct to also examine the server type.



 Comments   
Comment by Githook User [ 30/Apr/18 ]

Author:

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

Message: CDRIVER-2439 fix rs isMaster response for _test_dollar_query()

These tests attempted to simulate a primary or secondary, but the isMaster
response indicated a standalone due to the lack of "setName", "ismaster",
and "secondary" fields.
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/e1f042e76cb7a0a605acdecd0fef536b09e739da

Comment by Githook User [ 30/Apr/18 ]

Author:

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

Message: CDRIVER-2439 don't gossip cluster time to standalones

This addresses an edge case where an explicit session's cluster time may
have been manually advanced. Under normal usage, sessions used with a
standalone will always have an empty cluster time.
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/2f8fc08e42820a4286617e16fd708dcdf6404129

Comment by Jeremy Mikola [ 26/Apr/18 ]

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

Comment by Jeremy Mikola [ 26/Apr/18 ]

I do think the three bullets in SPEC-1015 that "advocate against sending $clusterTime to a standalone" justify addressing this.

I'd argue in favor of adding && server_type != MONGOC_SERVER_STANDALONE to this line and calling it a day.

Comment by A. Jesse Jiryu Davis [ 26/Apr/18 ]

jmikola, on SPEC-1015 Bernie wrote, "This situation seems so unlikely I don't think we should spend time changing all drivers to disallow it." Shall we make this C Driver change or ignore it?

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