Krinkle has uploaded a new change for review. ( 
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, 7 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/04/351204/1

diff --git a/includes/config/EtcdConfig.php b/includes/config/EtcdConfig.php
index f226f17..77b00bb 100644
--- a/includes/config/EtcdConfig.php
+++ b/includes/config/EtcdConfig.php
@@ -55,7 +55,7 @@
        /** @var integer */
        private $timeout;
        /** @var string */
-       private $directoryHash;
+       private $cacheKey;
 
        /**
         * @param array $params Parameter map:
@@ -81,7 +81,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 );
@@ -95,6 +94,11 @@
                        $this->srvCache = ObjectFactory::getObjectFromSpec( 
$params['cache'] );
                }
 
+               $this->cacheKey = $this->srvCache->makeGlobalKey(
+                       __CLASS__,
+                       $this->host,
+                       $this->directory
+               );
                $this->logger = new Psr\Log\NullLogger();
                $this->http = new MultiHttpClient( [
                        'connTimeout' => $this->timeout,
@@ -131,7 +135,7 @@
                }
 
                $now = microtime( true );
-               $key = $this->srvCache->makeKey( 'variable', 
$this->directoryHash );
+               $key = $this->cacheKey;
 
                // 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: newchange
Gerrit-Change-Id: I622e6618f2d4171626e4b272bcb11a97a85cb770
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to