Skip to content

Commit 9ce1238

Browse files
committed
PHPC-1422: Raise an actionable error message when retryWrites fails due to using an unsupported storage engine
1 parent 81ad619 commit 9ce1238

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
--TEST--
2+
Retryable writes: actionable error message when using retryable writes on unsupported storage engines
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php skip_if_not_libmongoc_crypto(); ?>
6+
<?php skip_if_not_server_storage_engine('mmapv1'); ?>
7+
<?php skip_if_not_replica_set(); ?>
8+
<?php skip_if_server_version('<', '3.6'); ?>
9+
<?php skip_if_not_clean(); ?>
10+
--FILE--
11+
<?php
12+
require_once __DIR__ . "/../utils/basic.inc";
13+
14+
$manager = new MongoDB\Driver\Manager(URI, ['retryWrites' => true]);
15+
$session = $manager->startSession();
16+
17+
echo throws(
18+
function() use ($manager, $session) {
19+
$command = new MongoDB\Driver\Command([
20+
'findAndModify' => COLLECTION_NAME,
21+
'query' => ['x' => 1],
22+
'update' => ['$inc' => ['x' => 1]],
23+
]);
24+
$manager->executeReadWriteCommand(DATABASE_NAME, $command, ['session' => $session]);
25+
},
26+
\MongoDB\Driver\Exception\CommandException::class
27+
);
28+
echo "\n";
29+
30+
?>
31+
===DONE===
32+
<?php exit(0); ?>
33+
--EXPECT--
34+
OK: Got MongoDB\Driver\Exception\CommandException
35+
This MongoDB deployment does not support retryable writes. Please add retryWrites=false to your connection string.
36+
===DONE===

0 commit comments

Comments
 (0)