Skip to content

flexible mysql retry handling#47

Merged
matthi4s merged 4 commits intomasterfrom
mysql-retry
Feb 11, 2026
Merged

flexible mysql retry handling#47
matthi4s merged 4 commits intomasterfrom
mysql-retry

Conversation

@matthi4s
Copy link
Member

No description provided.

@matthi4s matthi4s requested a review from Copilot February 10, 2026 13:12
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds configurable retry grouping for MySQLi operations, enabling different retry policies per error type (e.g., reconnect vs. deadlock).

Changes:

  • Introduces RetryGroup and RetryCollection abstractions to manage retry rules by status/error codes.
  • Updates Mysqli::rawQuery() and Mysqli::escape() to use the new retry collection and adds a retry hook (handleRetriedException()).
  • Replaces the old single connectionRetries mechanism and removes the setConnectionRetries() public API.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/Driver/Mysqli/RetryGroup.php New group primitive: maps status codes to a retry budget and tracks retry usage.
src/Driver/Mysqli/RetryCollection.php New collection: manages multiple retry groups and decides whether an error can be retried.
src/Driver/Mysqli/Mysqli.php Switches query/escape retry logic to the new collection and introduces a retry hook; removes old retry setter.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@matthi4s matthi4s requested a review from Copilot February 10, 2026 13:16
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@pavog pavog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, I find the term "retries" a bit confusing.
Because 1 retry means that it has already been tried twice. And 0 retries means: Tried once.

What do you think about changing from retries to attempts ?

}

/**
* @param array $statusCodes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int[] $statusCodes

*/
public function matchesStatusCodes(array $statusCodes): bool
{
foreach ($statusCodes as $statusCode) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also use

return array_any($statusCodes, fn($statusCode) => $this->matchesStatusCode($statusCode));

here

*/
protected function getRetryCollection(): RetryCollection
{
return new RetryCollection([
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure it's a good idea to set the retries to 1 and 3 by default?
The default behavior of PHP / Mysqli would be 1 try (-> 0 retries).
I'm concerned that people might overlook that this is implemented differently in this library.

@matthi4s matthi4s merged commit 56733ed into master Feb 11, 2026
3 checks passed
@matthi4s matthi4s deleted the mysql-retry branch February 11, 2026 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments