mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
Fix connection retry code to actually retry connections, instead of reading the
dead connection out of the connection cache. Summary: Test Plan: Reviewers: CC:
This commit is contained in:
parent
21650c47b6
commit
cf22d8c6cb
2 changed files with 22 additions and 5 deletions
|
@ -87,14 +87,31 @@ class AphrontMySQLDatabaseConnection extends AphrontDatabaseConnection {
|
|||
return idx($this->configuration, $key, $default);
|
||||
}
|
||||
|
||||
private function establishConnection() {
|
||||
private function closeConnection() {
|
||||
if ($this->connection) {
|
||||
$this->connection = null;
|
||||
$key = $this->getConnectionCacheKey();
|
||||
unset(self::$connectionCache[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
private function getConnectionCacheKey() {
|
||||
$user = $this->getConfiguration('user');
|
||||
$host = $this->getConfiguration('host');
|
||||
$database = $this->getConfiguration('database');
|
||||
|
||||
return "{$user}:{$host}:{$database}";
|
||||
}
|
||||
|
||||
|
||||
private function establishConnection() {
|
||||
$this->closeConnection();
|
||||
|
||||
$user = $this->getConfiguration('user');
|
||||
$host = $this->getConfiguration('host');
|
||||
$database = $this->getConfiguration('database');
|
||||
|
||||
$key = "{$user}:{$host}:{$database}";
|
||||
$key = $this->getConnectionCacheKey();
|
||||
if (isset(self::$connectionCache[$key])) {
|
||||
$this->connection = self::$connectionCache[$key];
|
||||
return;
|
||||
|
@ -176,7 +193,7 @@ class AphrontMySQLDatabaseConnection extends AphrontDatabaseConnection {
|
|||
$this->requireConnection();
|
||||
|
||||
$start = microtime(true);
|
||||
$result = mysql_query($raw_query, $this->connection);
|
||||
$result = @mysql_query($raw_query, $this->connection);
|
||||
$end = microtime(true);
|
||||
|
||||
DarkConsoleServicesPluginAPI::addEvent(
|
||||
|
@ -200,7 +217,7 @@ class AphrontMySQLDatabaseConnection extends AphrontDatabaseConnection {
|
|||
if ($this->isInsideTransaction()) {
|
||||
throw $ex;
|
||||
}
|
||||
$this->connection = null;
|
||||
$this->closeConnection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue