Skip to content

Commit

Permalink
Retry once when disabling fail points
Browse files Browse the repository at this point in the history
  • Loading branch information
jmikola committed Sep 24, 2024
1 parent c6c672e commit 14ec9f0
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 14ec9f0

Please sign in to comment.