From ec7b346af5e8f0ead566087845d434fea0e8bf89 Mon Sep 17 00:00:00 2001 From: MongoDB PHP Bot <162451593+mongodb-php-bot@users.noreply.github.com> Date: Tue, 24 Sep 2024 17:12:47 +0200 Subject: [PATCH] Merge v1.20 into v1.x (#1447) * Retry once when disabling fail points (#1445) The previous refactor in 90dcf186c8664a2cdd57314122d46b16234555c2 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 Co-authored-by: Andreas Braun --- tests/UnifiedSpecTests/ManagesFailPointsTrait.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/UnifiedSpecTests/ManagesFailPointsTrait.php b/tests/UnifiedSpecTests/ManagesFailPointsTrait.php index a1c313074..2680e89ac 100644 --- a/tests/UnifiedSpecTests/ManagesFailPointsTrait.php +++ b/tests/UnifiedSpecTests/ManagesFailPointsTrait.php @@ -2,6 +2,7 @@ namespace MongoDB\Tests\UnifiedSpecTests; +use MongoDB\Driver\Exception\ConnectionException; use MongoDB\Driver\Server; use MongoDB\Operation\DatabaseCommand; use stdClass; @@ -31,8 +32,14 @@ public function configureFailPoint(stdClass $failPoint, Server $server): void public function disableFailPoints(): void { foreach ($this->failPointsAndServers as [$failPoint, $server]) { - $operation = new DatabaseCommand('admin', ['configureFailPoint' => $failPoint, 'mode' => 'off']); - $operation->execute($server); + try { + $operation = new DatabaseCommand('admin', ['configureFailPoint' => $failPoint, 'mode' => 'off']); + $operation->execute($server); + } catch (ConnectionException) { + // Retry once in case the connection was dropped by the last operation + $operation = new DatabaseCommand('admin', ['configureFailPoint' => $failPoint, 'mode' => 'off']); + $operation->execute($server); + } } $this->failPointsAndServers = [];