-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Minor - P4
-
Affects Version/s: None
-
Component/s: libmongoc
-
None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
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.