PHPLIB-463: Prevent driver from retrying MapReduce operations

Running mapReduce commands through the executeReadCommand helper will cause the driver to retry the operation, as it should not inspect the command to catch mapReduce commands. To avoid this, we run mapReduce commands through the generic command helper which generally doesn't retry reads.
parent 0dcdfbaf
......@@ -271,9 +271,15 @@ class MapReduce implements Executable
$command = $this->createCommand($server);
$options = $this->createOptions($hasOutputCollection);
/* If the mapReduce operation results in a write, use
* executeReadWriteCommand to ensure we're handling the writeConcern
* option.
* In other cases, we use executeCommand as this will prevent the
* mapReduce operation from being retried when retryReads is enabled.
* See https://github.com/mongodb/specifications/blob/master/source/retryable-reads/retryable-reads.rst#unsupported-read-operations. */
$cursor = $hasOutputCollection
? $server->executeReadWriteCommand($this->databaseName, $command, $options)
: $server->executeReadCommand($this->databaseName, $command, $options);
: $server->executeCommand($this->databaseName, $command, $options);
if (isset($this->options['typeMap']) && ! $hasOutputCollection) {
$cursor->setTypeMap(create_field_path_type_map($this->options['typeMap'], 'results.$'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment