While running something similar to test #2 in the Driver Sessions spec, I received a server error ("afterClusterTime is not allowed for this command") on the second of two ping commands sent with the same explicit client session. This was using the generic mongoc_client_command_with_opts() command runner with the "sessionId" option.
According to the Causal Consistency spec:
The Read and Write Concern Specification states that drivers MUST NOT add a readConcern field to commands that are run using a generic runCommand method. The same is true for causal consistency, so commands that are run using runCommand MUST NOT have an afterClusterTime field added to them.
Looking at mongoc_cmd_parts_assemble(), I believe that we're entering this condition. libmongoc is only checking that the command is not a getMore before deciding to add a read concern with afterClusterTime. I think it may need to track whether the command supports a read concern (similar to is_write_command on mongoc_cmd_parts_t).
- is related to
-
PHPC-980 Implement Drivers Sessions API
- Closed
-
DRIVERS-2131 Test that generic runCommand sends no readConcern afterClusterTime
- Backlog
-
SERVER-31613 Commands that don't currently take any LockManager locks must not accept afterClusterTime
- Closed
- related to
-
CDRIVER-2422 mongoc_client_command_with_opts ignores readConcern option
- Closed