jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/385127 )
Change subject: objectcache: Always use interim values on WAN cache tombstones ...................................................................... objectcache: Always use interim values on WAN cache tombstones This stores values for very short times while the main value is a tombstone in case of particularly high traffic. Also make mutex keys expire immediately on unlock. Change-Id: I4ec5cf7f8b49239fdd2518e5d955534877a0f7ee --- M includes/libs/objectcache/WANObjectCache.php M tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php 2 files changed, 10 insertions(+), 4 deletions(-) Approvals: Krinkle: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/libs/objectcache/WANObjectCache.php b/includes/libs/objectcache/WANObjectCache.php index 15e5759..120ae45 100644 --- a/includes/libs/objectcache/WANObjectCache.php +++ b/includes/libs/objectcache/WANObjectCache.php @@ -964,6 +964,10 @@ // A deleted key with a negative TTL left must be tombstoned $isTombstone = ( $curTTL !== null && $value === false ); + if ( $isTombstone && $lockTSE <= 0 ) { + // Use the INTERIM value for tombstoned keys to reduce regeneration load + $lockTSE = 1; + } // Assume a key is hot if requested soon after invalidation $isHot = ( $curTTL !== null && $curTTL <= 0 && abs( $curTTL ) <= $lockTSE ); // Use the mutex if there is no value and a busy fallback is given @@ -1032,7 +1036,7 @@ if ( $lockAcquired ) { // Avoid using delete() to avoid pointless mcrouter broadcasting - $this->cache->changeTTL( self::MUTEX_KEY_PREFIX . $key, 1 ); + $this->cache->changeTTL( self::MUTEX_KEY_PREFIX . $key, (int)$preCallbackTime - 60 ); } return $value; @@ -1751,7 +1755,7 @@ return array_diff( $keys, $keysFound ); } - /** + /** * @param array $keys * @param array $checkKeys * @return array Map of (cache key => mixed) diff --git a/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php b/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php index c5a1759..e23f318 100644 --- a/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php +++ b/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php @@ -159,8 +159,9 @@ $this->assertEquals( 9, $hit, "Values evicted" ); $key = reset( $keys ); - // Get into cache + // Get into cache (default process cache group) $this->cache->getWithSetCallback( $key, 100, $callback, [ 'pcTTL' => 5 ] ); + $this->assertEquals( 10, $hit, "Value calculated" ); $this->cache->getWithSetCallback( $key, 100, $callback, [ 'pcTTL' => 5 ] ); $this->assertEquals( 10, $hit, "Value cached" ); $outerCallback = function () use ( &$callback, $key ) { @@ -168,7 +169,8 @@ return 43 + $v; }; - $this->cache->getWithSetCallback( $key, 100, $outerCallback ); + // Outer key misses and refuses inner key process cache value + $this->cache->getWithSetCallback( "$key-miss-outer", 100, $outerCallback ); $this->assertEquals( 11, $hit, "Nested callback value process cache skipped" ); } -- To view, visit https://gerrit.wikimedia.org/r/385127 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I4ec5cf7f8b49239fdd2518e5d955534877a0f7ee Gerrit-PatchSet: 8 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org> Gerrit-Reviewer: Krinkle <krinklem...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits