Skip to content

Commit 883a2ee

Browse files
authored
Retry once when disabling fail points (#1445)
The previous refactor in 90dcf18 changed when we disable fail points. ManagesFailPointTrait now does so immediately after test operations are run instead of during tear down, so we may be hitting a point where the server stream was disconnected and libmongoc is not recovering (possibly related to CDRIVER-4532). Adding an extra retry attempt seems to overcome this.
1 parent c6c672e commit 883a2ee

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Diff for: tests/UnifiedSpecTests/ManagesFailPointsTrait.php

+9-2
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 $e) {
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)