Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15424900
D20350.id48568.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.id48568.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,35 @@
'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 database connection to "%s" after connection '.
+ 'failure (attempt %d; "%s"; error #%d): %s',
+ $host,
+ $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
Mon, Mar 24, 12:59 AM (1 d, 11 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7708839
Default Alt Text
D20350.id48568.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