Skip to content

Commit 14ec9f0

Browse files
committed
Retry once when disabling fail points
1 parent c6c672e commit 14ec9f0

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tests/UnifiedSpecTests/ManagesFailPointsTrait.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace MongoDB\Tests\UnifiedSpecTests;
44

5+
use MongoDB\Driver\Exception\ConnectionException;
56
use MongoDB\Driver\Server;
67
use MongoDB\Operation\DatabaseCommand;
78
use stdClass;
@@ -31,8 +32,14 @@ public function configureFailPoint(stdClass $failPoint, Server $server): void
3132
public function disableFailPoints(): void
3233
{
3334
foreach ($this->failPointsAndServers as [$failPoint, $server]) {
34-
$operation = new DatabaseCommand('admin', ['configureFailPoint' => $failPoint, 'mode' => 'off']);
35-
$operation->execute($server);
35+
try {
36+
$operation = new DatabaseCommand('admin', ['configureFailPoint' => $failPoint, 'mode' => 'off']);
37+
$operation->execute($server);
38+
} catch (ConnectionException) {
39+
// Retry once in case the connection was dropped by the last operation
40+
$operation = new DatabaseCommand('admin', ['configureFailPoint' => $failPoint, 'mode' => 'off']);
41+
$operation->execute($server);
42+
}
3643
}
3744

3845
$this->failPointsAndServers = [];

0 commit comments

Comments
 (0)