mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-30 09:20:58 +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
|
@ -84,7 +84,7 @@ class PhabricatorSearchController extends PhabricatorSearchBaseController {
|
||||||
$handles,
|
$handles,
|
||||||
$query->getParameter('author', array()));
|
$query->getParameter('author', array()));
|
||||||
$author_value = mpull($author_value, 'getFullName', 'getPHID');
|
$author_value = mpull($author_value, 'getFullName', 'getPHID');
|
||||||
|
|
||||||
$owner_value = array_select_keys(
|
$owner_value = array_select_keys(
|
||||||
$handles,
|
$handles,
|
||||||
$query->getParameter('owner', array()));
|
$query->getParameter('owner', array()));
|
||||||
|
|
|
@ -87,14 +87,31 @@ class AphrontMySQLDatabaseConnection extends AphrontDatabaseConnection {
|
||||||
return idx($this->configuration, $key, $default);
|
return idx($this->configuration, $key, $default);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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() {
|
private function establishConnection() {
|
||||||
$this->connection = null;
|
$this->closeConnection();
|
||||||
|
|
||||||
$user = $this->getConfiguration('user');
|
$user = $this->getConfiguration('user');
|
||||||
$host = $this->getConfiguration('host');
|
$host = $this->getConfiguration('host');
|
||||||
$database = $this->getConfiguration('database');
|
$database = $this->getConfiguration('database');
|
||||||
|
|
||||||
$key = "{$user}:{$host}:{$database}";
|
$key = $this->getConnectionCacheKey();
|
||||||
if (isset(self::$connectionCache[$key])) {
|
if (isset(self::$connectionCache[$key])) {
|
||||||
$this->connection = self::$connectionCache[$key];
|
$this->connection = self::$connectionCache[$key];
|
||||||
return;
|
return;
|
||||||
|
@ -176,7 +193,7 @@ class AphrontMySQLDatabaseConnection extends AphrontDatabaseConnection {
|
||||||
$this->requireConnection();
|
$this->requireConnection();
|
||||||
|
|
||||||
$start = microtime(true);
|
$start = microtime(true);
|
||||||
$result = mysql_query($raw_query, $this->connection);
|
$result = @mysql_query($raw_query, $this->connection);
|
||||||
$end = microtime(true);
|
$end = microtime(true);
|
||||||
|
|
||||||
DarkConsoleServicesPluginAPI::addEvent(
|
DarkConsoleServicesPluginAPI::addEvent(
|
||||||
|
@ -200,7 +217,7 @@ class AphrontMySQLDatabaseConnection extends AphrontDatabaseConnection {
|
||||||
if ($this->isInsideTransaction()) {
|
if ($this->isInsideTransaction()) {
|
||||||
throw $ex;
|
throw $ex;
|
||||||
}
|
}
|
||||||
$this->connection = null;
|
$this->closeConnection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue