@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+18 -8
+18 -8
src/infrastructure/storage/lisk/LiskDAO.php
··· 302 302 */ 303 303 protected function setEstablishedConnection( 304 304 $mode, 305 - AphrontDatabaseConnection $connection) { 305 + AphrontDatabaseConnection $connection, 306 + $force_unique = false) { 306 307 307 308 $key = $this->getConnectionNamespace().':'.$mode; 309 + 310 + if ($force_unique) { 311 + $key .= ':unique'; 312 + while (isset(self::$connections[$key])) { 313 + $key .= '!'; 314 + } 315 + } 316 + 308 317 self::$connections[$key] = $connection; 309 318 return $this; 310 319 } ··· 483 492 * 484 493 * @task load 485 494 */ 486 - public function loadAllWhere($pattern/*, $arg, $arg, $arg ... */) { 495 + public function loadAllWhere($pattern/* , $arg, $arg, $arg ... */) { 487 496 $args = func_get_args(); 488 497 array_unshift($args, null); 489 498 $data = call_user_func_array( ··· 503 512 * 504 513 * @task load 505 514 */ 506 - public function loadColumnsWhere(array $columns, $pattern/*, $args... */) { 515 + public function loadColumnsWhere(array $columns, $pattern/* , $args... */) { 507 516 if (!$this->getConfigOption(self::CONFIG_PARTIAL_OBJECTS)) { 508 517 throw new BadMethodCallException( 509 518 "This class does not support partial objects."); ··· 528 537 * 529 538 * @task load 530 539 */ 531 - public function loadOneWhere($pattern/*, $arg, $arg, $arg ... */) { 540 + public function loadOneWhere($pattern/* , $arg, $arg, $arg ... */) { 532 541 $args = func_get_args(); 533 542 array_unshift($args, null); 534 543 $data = call_user_func_array( ··· 549 558 } 550 559 551 560 552 - protected function loadRawDataWhere($columns, $pattern/*, $args... */) { 561 + protected function loadRawDataWhere($columns, $pattern/* , $args... */) { 553 562 $connection = $this->establishConnection('r'); 554 563 555 564 $lock_clause = ''; ··· 1009 1018 if (self::shouldIsolateAllLiskEffectsToTransactions()) { 1010 1019 $connection->openTransaction(); 1011 1020 } 1012 - if (!$force_new) { 1013 - $this->setEstablishedConnection($mode, $connection); 1014 - } 1021 + $this->setEstablishedConnection( 1022 + $mode, 1023 + $connection, 1024 + $force_unique = $force_new); 1015 1025 } 1016 1026 1017 1027 return $connection;