jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/372228 )
Change subject: Remove "memCache" field from LoadBalancer
......................................................................
Remove "memCache" field from LoadBalancer
The only user was LoadMonitor, which is converted to only use
the WAN and server caches. Previously, the lock() calls there
were useless since LBFactory never injected "memcCache" to
LoadBalancer, ergo making it EmptyBagOStuff in LoadMonitor.
Change-Id: I0c7793d47b93b763dee478d16fb87ec637dc6cab
---
M includes/libs/rdbms/loadbalancer/ILoadBalancer.php
M includes/libs/rdbms/loadbalancer/LoadBalancer.php
M includes/libs/rdbms/loadmonitor/ILoadMonitor.php
M includes/libs/rdbms/loadmonitor/LoadMonitor.php
M includes/libs/rdbms/loadmonitor/LoadMonitorMySQL.php
M includes/libs/rdbms/loadmonitor/LoadMonitorNull.php
6 files changed, 21 insertions(+), 25 deletions(-)
Approvals:
Krinkle: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/libs/rdbms/loadbalancer/ILoadBalancer.php
b/includes/libs/rdbms/loadbalancer/ILoadBalancer.php
index fc50961..c940392 100644
--- a/includes/libs/rdbms/loadbalancer/ILoadBalancer.php
+++ b/includes/libs/rdbms/loadbalancer/ILoadBalancer.php
@@ -94,7 +94,6 @@
* - readOnlyReason : Reason the master DB is read-only if so
[optional]
* - waitTimeout : Maximum time to wait for replicas for consistency
[optional]
* - srvCache : BagOStuff object for server cache [optional]
- * - memCache : BagOStuff object for cluster memory cache [optional]
* - wanCache : WANObjectCache object [optional]
* - chronologyProtector: ChronologyProtector object [optional]
* - hostname : The name of the current server [optional]
diff --git a/includes/libs/rdbms/loadbalancer/LoadBalancer.php
b/includes/libs/rdbms/loadbalancer/LoadBalancer.php
index 72217da..1df2409 100644
--- a/includes/libs/rdbms/loadbalancer/LoadBalancer.php
+++ b/includes/libs/rdbms/loadbalancer/LoadBalancer.php
@@ -62,8 +62,6 @@
private $chronProt;
/** @var BagOStuff */
private $srvCache;
- /** @var BagOStuff */
- private $memCache;
/** @var WANObjectCache */
private $wanCache;
/** @var object|string Class name or object With profileIn/profileOut
methods */
@@ -187,11 +185,6 @@
} else {
$this->srvCache = new EmptyBagOStuff();
}
- if ( isset( $params['memCache'] ) ) {
- $this->memCache = $params['memCache'];
- } else {
- $this->memCache = new EmptyBagOStuff();
- }
if ( isset( $params['wanCache'] ) ) {
$this->wanCache = $params['wanCache'];
} else {
@@ -244,7 +237,7 @@
}
$this->loadMonitor = new $class(
- $this, $this->srvCache, $this->memCache,
$this->loadMonitorConfig );
+ $this, $this->srvCache, $this->wanCache,
$this->loadMonitorConfig );
$this->loadMonitor->setLogger( $this->replLogger );
}
diff --git a/includes/libs/rdbms/loadmonitor/ILoadMonitor.php
b/includes/libs/rdbms/loadmonitor/ILoadMonitor.php
index 4f6701f..fba5e13 100644
--- a/includes/libs/rdbms/loadmonitor/ILoadMonitor.php
+++ b/includes/libs/rdbms/loadmonitor/ILoadMonitor.php
@@ -25,6 +25,7 @@
use Psr\Log\LoggerAwareInterface;
use BagOStuff;
+use WANObjectCache;
/**
* An interface for database load monitoring
@@ -37,11 +38,11 @@
*
* @param ILoadBalancer $lb LoadBalancer this instance serves
* @param BagOStuff $sCache Local server memory cache
- * @param BagOStuff $cCache Local cluster memory cache
+ * @param WANObjectCache $wCache Local cluster memory cache
* @param array $options Options map
*/
public function __construct(
- ILoadBalancer $lb, BagOStuff $sCache, BagOStuff $cCache, array
$options = []
+ ILoadBalancer $lb, BagOStuff $sCache, WANObjectCache $wCache,
array $options = []
);
/**
diff --git a/includes/libs/rdbms/loadmonitor/LoadMonitor.php
b/includes/libs/rdbms/loadmonitor/LoadMonitor.php
index 4300e9f..d4e73c9 100644
--- a/includes/libs/rdbms/loadmonitor/LoadMonitor.php
+++ b/includes/libs/rdbms/loadmonitor/LoadMonitor.php
@@ -25,6 +25,7 @@
use Psr\Log\NullLogger;
use Wikimedia\ScopedCallback;
use BagOStuff;
+use WANObjectCache;
/**
* Basic DB load monitor with no external dependencies
@@ -37,8 +38,8 @@
protected $parent;
/** @var BagOStuff */
protected $srvCache;
- /** @var BagOStuff */
- protected $mainCache;
+ /** @var WANObjectCache */
+ protected $wanCache;
/** @var LoggerInterface */
protected $replLogger;
@@ -48,11 +49,11 @@
const VERSION = 1; // cache key version
public function __construct(
- ILoadBalancer $lb, BagOStuff $srvCache, BagOStuff $cache, array
$options = []
+ ILoadBalancer $lb, BagOStuff $srvCache, WANObjectCache $wCache,
array $options = []
) {
$this->parent = $lb;
$this->srvCache = $srvCache;
- $this->mainCache = $cache;
+ $this->wanCache = $wCache;
$this->replLogger = new NullLogger();
$this->movingAveRatio = isset( $options['movingAveRatio'] )
@@ -109,7 +110,7 @@
$staleValue = $value ?: false;
# (b) Check the shared cache and backfill APC
- $value = $this->mainCache->get( $key );
+ $value = $this->wanCache->get( $key );
if ( $value && $value['timestamp'] > ( microtime( true ) - $ttl
) ) {
$this->srvCache->set( $key, $value, $staleTTL );
$this->replLogger->debug( __METHOD__ . ": got lag times
($key) from main cache" );
@@ -119,12 +120,12 @@
$staleValue = $value ?: $staleValue;
# (c) Cache key missing or expired; regenerate and backfill
- if ( $this->mainCache->lock( $key, 0, 10 ) ) {
- # Let this process alone update the cache value
- $cache = $this->mainCache;
+ if ( $this->srvCache->lock( $key, 0, 10 ) ) {
+ # Let only this process update the cache value on this
server
+ $sCache = $this->srvCache;
/** @noinspection PhpUnusedLocalVariableInspection */
- $unlocker = new ScopedCallback( function () use (
$cache, $key ) {
- $cache->unlock( $key );
+ $unlocker = new ScopedCallback( function () use (
$sCache, $key ) {
+ $sCache->unlock( $key );
} );
} elseif ( $staleValue ) {
# Could not acquire lock but an old cache exists, so
use it
@@ -196,7 +197,7 @@
'weightScales' => $weightScales,
'timestamp' => microtime( true )
];
- $this->mainCache->set( $key, $value, $staleTTL );
+ $this->wanCache->set( $key, $value, $staleTTL );
$this->srvCache->set( $key, $value, $staleTTL );
$this->replLogger->info( __METHOD__ . ": re-calculated lag
times ($key)" );
diff --git a/includes/libs/rdbms/loadmonitor/LoadMonitorMySQL.php
b/includes/libs/rdbms/loadmonitor/LoadMonitorMySQL.php
index ff72dbc..f8ad329 100644
--- a/includes/libs/rdbms/loadmonitor/LoadMonitorMySQL.php
+++ b/includes/libs/rdbms/loadmonitor/LoadMonitorMySQL.php
@@ -22,6 +22,7 @@
namespace Wikimedia\Rdbms;
use BagOStuff;
+use WANObjectCache;
/**
* Basic MySQL load monitor with no external dependencies
@@ -34,9 +35,9 @@
private $warmCacheRatio;
public function __construct(
- ILoadBalancer $lb, BagOStuff $srvCache, BagOStuff $cache, array
$options = []
+ ILoadBalancer $lb, BagOStuff $srvCache, WANObjectCache $wCache,
array $options = []
) {
- parent::__construct( $lb, $srvCache, $cache, $options );
+ parent::__construct( $lb, $srvCache, $wCache, $options );
$this->warmCacheRatio = isset( $options['warmCacheRatio'] )
? $options['warmCacheRatio']
diff --git a/includes/libs/rdbms/loadmonitor/LoadMonitorNull.php
b/includes/libs/rdbms/loadmonitor/LoadMonitorNull.php
index 8bbf9e5..6dae8cc 100644
--- a/includes/libs/rdbms/loadmonitor/LoadMonitorNull.php
+++ b/includes/libs/rdbms/loadmonitor/LoadMonitorNull.php
@@ -23,10 +23,11 @@
use Psr\Log\LoggerInterface;
use BagOStuff;
+use WANObjectCache;
class LoadMonitorNull implements ILoadMonitor {
public function __construct(
- ILoadBalancer $lb, BagOStuff $sCache, BagOStuff $cCache, array
$options = []
+ ILoadBalancer $lb, BagOStuff $sCache, WANObjectCache $wCache,
array $options = []
) {
}
--
To view, visit https://gerrit.wikimedia.org/r/372228
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0c7793d47b93b763dee478d16fb87ec637dc6cab
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits