mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-27 01:02:42 +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(
|
protected function setEstablishedConnection(
|
||||||
$mode,
|
$mode,
|
||||||
AphrontDatabaseConnection $connection) {
|
AphrontDatabaseConnection $connection,
|
||||||
|
$force_unique = false) {
|
||||||
|
|
||||||
$key = $this->getConnectionNamespace().':'.$mode;
|
$key = $this->getConnectionNamespace().':'.$mode;
|
||||||
|
|
||||||
|
if ($force_unique) {
|
||||||
|
$key .= ':unique';
|
||||||
|
while (isset(self::$connections[$key])) {
|
||||||
|
$key .= '!';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
self::$connections[$key] = $connection;
|
self::$connections[$key] = $connection;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -1009,9 +1018,10 @@ abstract class LiskDAO {
|
||||||
if (self::shouldIsolateAllLiskEffectsToTransactions()) {
|
if (self::shouldIsolateAllLiskEffectsToTransactions()) {
|
||||||
$connection->openTransaction();
|
$connection->openTransaction();
|
||||||
}
|
}
|
||||||
if (!$force_new) {
|
$this->setEstablishedConnection(
|
||||||
$this->setEstablishedConnection($mode, $connection);
|
$mode,
|
||||||
}
|
$connection,
|
||||||
|
$force_unique = $force_new);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $connection;
|
return $connection;
|
||||||
|
|
Loading…
Reference in a new issue