PHPC-689: Use mongoc_cursor_set_hint() for query/command execution #316
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
https://jira.mongodb.org/browse/PHPC-689
We currently have two test failures:
Both of these tests expected RuntimeExceptions to be thrown due to "not master and slaveOk=false"; however,
mongoc_cursor_set_hint()
now forces theslaveOk
flag (see: CDRIVER-903). With that change, the queries are now sent to the secondary server:executeCommand()
fails with a different RuntimeException message: "Failed to decode document from the server." originating from_mongoc_rpc_parse_error()
. This will require some investigation (viamongodb.debug
tracing) to see what is actually being sent to the secondary. It is unclear if the error is within PHPC or libmongoc.executeQuery()
simply executes and returns a cursor.The Server method documentation has the following notes about the
$readPreference
parameter:The bit about "setting the wire protocol accordingly" is no longer relevant, since
slaveOk
will always be set. I would only expect the read preference to be used when communicating with a mongos node. We should create new tests to verify that behavior (tracking in PHPC-691).In the meantime, the aforementioned tests should be revised to no longer expect exceptions and we should make necessary changes to PHPC or libmongoc to ensure that the
executeCommand()
test passes.