Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUGFIX: Adjust DoctrineEventStorage commit retry attempts #289

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Classes/EventStore/Storage/Doctrine/DoctrineEventStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ public function commit(StreamName $streamName, WritableEvents $events, int $expe
throw new \InvalidArgumentException(sprintf('Can\'t commit to virtual stream "%s"', $streamName), 1540632984);
}

# Exponential backoff: initial interval = 5ms and 8 retry attempts = max 1275ms (= 1,275 seconds)
# @see http://backoffcalculator.com/?attempts=8&rate=2&interval=5
# Exponential backoff: initial interval = 5ms and 25 retry attempts = max 2360ms (= 2,36 seconds)
# @see http://backoffcalculator.com/?attempts=25&interval=0.005&rate=1.2
$retryWaitInterval = 0.005;
$maxRetryAttempts = 8;
$maxRetryAttempts = 25;
$retryAttempt = 0;
while (true) {
$this->reconnectDatabaseConnection();
Expand All @@ -144,7 +144,7 @@ public function commit(StreamName $streamName, WritableEvents $events, int $expe
}
usleep((int)($retryWaitInterval * 1E6));
$retryAttempt++;
$retryWaitInterval *= 2;
$retryWaitInterval *= 1.2;
$this->connection->rollBack();
continue;
} catch (DBALException | ConcurrencyException $exception) {
Expand Down