From 83e294a892b20ecea60ca1aaeef85eb06714084f Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sun, 21 Jul 2019 01:02:49 -0700 Subject: [PATCH] Convert LoadBalancer::getConnection() callers to LoadBalancer::getConnectionRef() Change-Id: Ie1ae322202105ce093779e6d0b00f335c71be31f --- includes/Revision/RevisionStore.php | 2 +- includes/SiteStatsInit.php | 6 +++--- includes/Storage/SqlBlobStore.php | 2 +- includes/objectcache/SqlBagOStuff.php | 7 ++++--- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/includes/Revision/RevisionStore.php b/includes/Revision/RevisionStore.php index 8a4b6dcfaf..fe5b5b94e9 100644 --- a/includes/Revision/RevisionStore.php +++ b/includes/Revision/RevisionStore.php @@ -284,7 +284,7 @@ class RevisionStore */ private function getDBConnection( $mode, $groups = [] ) { $lb = $this->getDBLoadBalancer(); - return $lb->getConnection( $mode, $groups, $this->dbDomain ); + return $lb->getConnectionRef( $mode, $groups, $this->dbDomain ); } /** diff --git a/includes/SiteStatsInit.php b/includes/SiteStatsInit.php index 932e1c3d55..2252f8f4ff 100644 --- a/includes/SiteStatsInit.php +++ b/includes/SiteStatsInit.php @@ -195,8 +195,8 @@ class SiteStatsInit { * @return IDatabase */ private static function getDB( $index, $groups = [] ) { - $lb = MediaWikiServices::getInstance()->getDBLoadBalancer(); - - return $lb->getConnection( $index, $groups ); + return MediaWikiServices::getInstance() + ->getDBLoadBalancer() + ->getConnectionRef( $index, $groups ); } } diff --git a/includes/Storage/SqlBlobStore.php b/includes/Storage/SqlBlobStore.php index 5260754f5f..d1b688b201 100644 --- a/includes/Storage/SqlBlobStore.php +++ b/includes/Storage/SqlBlobStore.php @@ -207,7 +207,7 @@ class SqlBlobStore implements IDBAccessObject, BlobStore { */ private function getDBConnection( $index ) { $lb = $this->getDBLoadBalancer(); - return $lb->getConnection( $index, [], $this->dbDomain ); + return $lb->getConnectionRef( $index, [], $this->dbDomain ); } /** diff --git a/includes/objectcache/SqlBagOStuff.php b/includes/objectcache/SqlBagOStuff.php index 9226875e2a..6cc63bffb3 100644 --- a/includes/objectcache/SqlBagOStuff.php +++ b/includes/objectcache/SqlBagOStuff.php @@ -27,6 +27,7 @@ use Wikimedia\Rdbms\IDatabase; use Wikimedia\Rdbms\DBError; use Wikimedia\Rdbms\DBQueryError; use Wikimedia\Rdbms\DBConnectionError; +use Wikimedia\Rdbms\IMaintainableDatabase; use Wikimedia\Rdbms\LoadBalancer; use Wikimedia\ScopedCallback; use Wikimedia\WaitConditionLoop; @@ -165,7 +166,7 @@ class SqlBagOStuff extends MediumSpecificBagOStuff { * Get a connection to the specified database * * @param int $serverIndex - * @return Database + * @return IMaintainableDatabase * @throws MWException */ protected function getDB( $serverIndex ) { @@ -199,11 +200,11 @@ class SqlBagOStuff extends MediumSpecificBagOStuff { $index = $this->replicaOnly ? DB_REPLICA : DB_MASTER; if ( $lb->getServerType( $lb->getWriterIndex() ) !== 'sqlite' ) { // Keep a separate connection to avoid contention and deadlocks - $db = $lb->getConnection( $index, [], false, $lb::CONN_TRX_AUTOCOMMIT ); + $db = $lb->getConnectionRef( $index, [], false, $lb::CONN_TRX_AUTOCOMMIT ); } else { // However, SQLite has the opposite behavior due to DB-level locking. // Stock sqlite MediaWiki installs use a separate sqlite cache DB instead. - $db = $lb->getConnection( $index ); + $db = $lb->getConnectionRef( $index ); } } -- 2.20.1