Skip to content

Commit ec7b346

Browse files
mongodb-php-botjmikolaalcaeus
authored
Merge v1.20 into v1.x (#1447)
* 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. * Use non-capturing catch statement --------- Co-authored-by: Jeremy Mikola <[email protected]> Co-authored-by: Andreas Braun <[email protected]>
1 parent 72d205f commit ec7b346

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)