Daniel Kinzler has uploaded a new change for review.
https://gerrit.wikimedia.org/r/189503
Change subject: Re-use connection manager.
......................................................................
Re-use connection manager.
In order to benefit from the "use master once, use master always" logic,
we need to re-use the ConnectionManager instance for all services.
Bug: T88357
Change-Id: I3290845320466945ec8f688b248a9ca2359e59b8
---
M client/includes/store/sql/DirectSqlStore.php
1 file changed, 26 insertions(+), 12 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/03/189503/1
diff --git a/client/includes/store/sql/DirectSqlStore.php
b/client/includes/store/sql/DirectSqlStore.php
index c8dbeb0..9ddffd6 100644
--- a/client/includes/store/sql/DirectSqlStore.php
+++ b/client/includes/store/sql/DirectSqlStore.php
@@ -3,7 +3,6 @@
namespace Wikibase;
use HashBagOStuff;
-use LoadBalancer;
use ObjectCache;
use Wikibase\Client\Store\Sql\ConnectionManager;
use Wikibase\Client\Store\Sql\PagePropsEntityIdLookup;
@@ -55,6 +54,16 @@
* @var string|bool The symbolic database name of the repo wiki or
false for the local wiki.
*/
private $repoWiki;
+
+ /**
+ * @var ConnectionManager|null
+ */
+ private $repoConnectionManager = null;
+
+ /**
+ * @var ConnectionManager|null
+ */
+ private $localConnectionManager = null;
/**
* @var string
@@ -174,10 +183,7 @@
if ( $this->useLegacyChangesSubscription ) {
$this->subscriptionManager = new
NullSubscriptionManager();
} else {
- $connectionManager = new ConnectionManager(
- $this->getRepoLoadBalancer(),
- $this->repoWiki
- );
+ $connectionManager =
$this->getRepoConnectionManager();
$this->subscriptionManager = new
SqlSubscriptionManager( $connectionManager );
}
}
@@ -189,20 +195,28 @@
* Returns a LoadBalancer that acts as a factory for connections to the
repo wiki's
* database.
*
- * @return LoadBalancer
+ * @return ConnectionManager
*/
- private function getRepoLoadBalancer() {
- return wfGetLB( $this->repoWiki );
+ private function getRepoConnectionManager() {
+ if ( $this->repoConnectionManager === null ) {
+ $this->repoConnectionManager = new ConnectionManager(
wfGetLB( $this->repoWiki ), $this->repoWiki );
+ }
+
+ return $this->repoConnectionManager;
}
/**
* Returns a LoadBalancer that acts as a factory for connections to the
local (client) wiki's
* database.
*
- * @return LoadBalancer
+ * @return ConnectionManager
*/
- private function getLocalLoadBalancer() {
- return wfGetLB();
+ private function getLocalConnectionManager() {
+ if ( $this->localConnectionManager === null ) {
+ $this->localConnectionManager = new ConnectionManager(
wfGetLB() );
+ }
+
+ return $this->localConnectionManager;
}
/**
@@ -240,7 +254,7 @@
if ( $this->useLegacyUsageIndex ) {
$this->usageTracker = new NullUsageTracker();
} else {
- $connectionManager = new ConnectionManager(
$this->getLocalLoadBalancer() );
+ $connectionManager =
$this->getLocalConnectionManager();
$this->usageTracker = new SqlUsageTracker(
$this->entityIdParser, $connectionManager );
}
}
--
To view, visit https://gerrit.wikimedia.org/r/189503
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3290845320466945ec8f688b248a9ca2359e59b8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits