Skip to content

Commit

Permalink
Merge v1.20 into v1.x (#1447)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Sep 24, 2024
1 parent 72d205f commit ec7b346
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tests/UnifiedSpecTests/ManagesFailPointsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace MongoDB\Tests\UnifiedSpecTests;

use MongoDB\Driver\Exception\ConnectionException;
use MongoDB\Driver\Server;
use MongoDB\Operation\DatabaseCommand;
use stdClass;
Expand Down Expand Up @@ -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 = [];
Expand Down

0 comments on commit ec7b346

Please sign in to comment.