jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/351204 )
Change subject: config: Use less generic cache key, and not fragmented by wiki
......................................................................
config: Use less generic cache key, and not fragmented by wiki
* Use makeGlobalKey instead of makeKey to avoid fragmenting
the cache by the wiki-specific key space.
* Add "EtcdConfig" and $this->host to the cache key to make
it less generic and less likely to conflict with unrelated values
in case multiple instances exist somewhere in the MediaWiki run
time (or during testing/debugging).
Adding $this->host should be fine given we were already including
the directory within that host. Although I do recognise that we
may want to encourage slow cache rollover instead of instance
cache rollover in case the host name needs to changed. Perhaps
we should have some kind of canonical name for the instance for
the purpose of caching so that directory or host can be changed
without changing the cache key, and thus have cache roll over
normally over the course of 10 seconds, instead of immediately.
On the other hand, deployment will likely already spread things
out a little bit.
In addition, due to the cache being kept indefinitely this means
the old key will stay indefinitely. Perhaps not an issue given
it's just one key, which will clear on restart eventually?
Bug: T156924
Change-Id: I622e6618f2d4171626e4b272bcb11a97a85cb770
---
M includes/config/EtcdConfig.php
1 file changed, 5 insertions(+), 4 deletions(-)
Approvals:
Aaron Schulz: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/config/EtcdConfig.php b/includes/config/EtcdConfig.php
index f226f17..fd5c3f7 100644
--- a/includes/config/EtcdConfig.php
+++ b/includes/config/EtcdConfig.php
@@ -54,8 +54,6 @@
private $skewCacheTTL;
/** @var integer */
private $timeout;
- /** @var string */
- private $directoryHash;
/**
* @param array $params Parameter map:
@@ -81,7 +79,6 @@
$this->host = $params['host'];
$this->protocol = $params['protocol'];
$this->directory = trim( $params['directory'], '/' );
- $this->directoryHash = sha1( $this->directory );
$this->encoding = $params['encoding'];
$this->skewCacheTTL = $params['skewTTL'];
$this->baseCacheTTL = max( $params['cacheTTL'] -
$this->skewCacheTTL, 0 );
@@ -131,7 +128,11 @@
}
$now = microtime( true );
- $key = $this->srvCache->makeKey( 'variable',
$this->directoryHash );
+ $key = $this->srvCache->makeGlobalKey(
+ __CLASS__,
+ $this->host,
+ $this->directory
+ );
// Get the cached value or block until it is regenerated (by
this or another thread)...
$data = null; // latest config info
--
To view, visit https://gerrit.wikimedia.org/r/351204
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I622e6618f2d4171626e4b272bcb11a97a85cb770
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Tim Starling <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits