Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15384302
D20350.id48566.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D20350.id48566.diff
View Options
diff --git a/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php b/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php
--- a/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php
+++ b/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php
@@ -95,17 +95,33 @@
'database' => $database,
));
- $retries = max(1, $this->getConfiguration('retries', 3));
- while ($retries--) {
+ // If we receive these errors, we'll retry the connection up to the
+ // retry limit. For other errors, we'll fail immediately.
+ $retry_codes = array(
+ // "Connection Timeout"
+ 2002 => true,
+
+ // "Unable to Connect"
+ 2003 => true,
+ );
+
+ $max_retries = max(1, $this->getConfiguration('retries', 3));
+ for ($attempt = 1; $attempt <= $max_retries; $attempt++) {
try {
$conn = $this->connect();
$profiler->endServiceCall($call_id, array());
break;
} catch (AphrontQueryException $ex) {
- if ($retries && $ex->getCode() == 2003) {
- $class = get_class($ex);
- $message = $ex->getMessage();
- phlog(pht('Retrying (%d) after %s: %s', $retries, $class, $message));
+ $code = $ex->getCode();
+ if (($attempt < $max_retries) && isset($retry_codes[$code])) {
+ $message = pht(
+ 'Retrying (attempt %d) after connection failure ("%s", #%d): %s',
+ $attempt,
+ get_class($ex),
+ $code,
+ $ex->getMessage());
+
+ phlog($message);
} else {
$profiler->endServiceCall($call_id, array());
throw $ex;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mar 15 2025, 7:27 PM (6 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7702328
Default Alt Text
D20350.id48566.diff (1 KB)
Attached To
Mode
D20350: Retry connections on timeouts, and raise more readable connection failure messages
Attached
Detach File
Event Timeline
Log In to Comment