mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
Store forced connections in the Lisk connection cache
Summary: In unit tests which use fixtures, we open transactions on every connection we establish. However, since we don't track connections that are established with "$force_new" (currently, only GlobalLock connections) we never close these transactions normally. Instead of not tracking these connections, track them using unique keys so we'll never get a cache hit on them. Test Plan: Built unit tests on top of this, had them stop dying from unclosed transactions. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T1162 Differential Revision: https://secure.phabricator.com/D2938
This commit is contained in:
parent
7cf6313be9
commit
d86c4e0366
1 changed files with 18 additions and 8 deletions
|
@ -302,9 +302,18 @@ abstract class LiskDAO {
|
|||
*/
|
||||
protected function setEstablishedConnection(
|
||||
$mode,
|
||||
AphrontDatabaseConnection $connection) {
|
||||
AphrontDatabaseConnection $connection,
|
||||
$force_unique = false) {
|
||||
|
||||
$key = $this->getConnectionNamespace().':'.$mode;
|
||||
|
||||
if ($force_unique) {
|
||||
$key .= ':unique';
|
||||
while (isset(self::$connections[$key])) {
|
||||
$key .= '!';
|
||||
}
|
||||
}
|
||||
|
||||
self::$connections[$key] = $connection;
|
||||
return $this;
|
||||
}
|
||||
|
@ -483,7 +492,7 @@ abstract class LiskDAO {
|
|||
*
|
||||
* @task load
|
||||
*/
|
||||
public function loadAllWhere($pattern/*, $arg, $arg, $arg ... */) {
|
||||
public function loadAllWhere($pattern/* , $arg, $arg, $arg ... */) {
|
||||
$args = func_get_args();
|
||||
array_unshift($args, null);
|
||||
$data = call_user_func_array(
|
||||
|
@ -503,7 +512,7 @@ abstract class LiskDAO {
|
|||
*
|
||||
* @task load
|
||||
*/
|
||||
public function loadColumnsWhere(array $columns, $pattern/*, $args... */) {
|
||||
public function loadColumnsWhere(array $columns, $pattern/* , $args... */) {
|
||||
if (!$this->getConfigOption(self::CONFIG_PARTIAL_OBJECTS)) {
|
||||
throw new BadMethodCallException(
|
||||
"This class does not support partial objects.");
|
||||
|
@ -528,7 +537,7 @@ abstract class LiskDAO {
|
|||
*
|
||||
* @task load
|
||||
*/
|
||||
public function loadOneWhere($pattern/*, $arg, $arg, $arg ... */) {
|
||||
public function loadOneWhere($pattern/* , $arg, $arg, $arg ... */) {
|
||||
$args = func_get_args();
|
||||
array_unshift($args, null);
|
||||
$data = call_user_func_array(
|
||||
|
@ -549,7 +558,7 @@ abstract class LiskDAO {
|
|||
}
|
||||
|
||||
|
||||
protected function loadRawDataWhere($columns, $pattern/*, $args... */) {
|
||||
protected function loadRawDataWhere($columns, $pattern/* , $args... */) {
|
||||
$connection = $this->establishConnection('r');
|
||||
|
||||
$lock_clause = '';
|
||||
|
@ -1009,9 +1018,10 @@ abstract class LiskDAO {
|
|||
if (self::shouldIsolateAllLiskEffectsToTransactions()) {
|
||||
$connection->openTransaction();
|
||||
}
|
||||
if (!$force_new) {
|
||||
$this->setEstablishedConnection($mode, $connection);
|
||||
}
|
||||
$this->setEstablishedConnection(
|
||||
$mode,
|
||||
$connection,
|
||||
$force_unique = $force_new);
|
||||
}
|
||||
|
||||
return $connection;
|
||||
|
|
Loading…
Reference in a new issue