aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/Storage/NameTableStoreTest.php
diff options
context:
space:
mode:
authorAaron Schulz <aschulz@wikimedia.org>2019-02-26 17:04:24 -0800
committerAaron Schulz <aschulz@wikimedia.org>2019-03-04 10:00:29 +0000
commitb707afa7f485e4908a069931f689852c493bac8b (patch)
treeb3deea83f366a53cb94e2a5eab4086a64b95cd43 /tests/phpunit/includes/Storage/NameTableStoreTest.php
parent9b4461c1b8027049d575bc66b45a1545bd506188 (diff)
downloadmediawikicore-b707afa7f485e4908a069931f689852c493bac8b.tar.gz
mediawikicore-b707afa7f485e4908a069931f689852c493bac8b.zip
objectcache: optimize WAN cache key updates during HOLDOFF_TTL
Avoid the ADD operation spam from all threads trying to access a tombstoned key by checking the interim value cache timestamp. This also avoids the GET/CAS spam from threads that manage to get the mutex. If a single thread repeatedly accesses the same tombstoned value in rapid succession, there will significantly less cache operation spam. Do the same for cache updates to keys in the holdoff state due to "check keys" or the "touchedCallback" function. Relatedly, fix getWithSetCallback() to disregard interim values set prior to or at the same time as the latest delete() call. This can slightly reduce the chance of the cache being behind replica DBs for a second. It also avoids unit test failures were a series of deletes and cache access happen at the same timestamp (via time injection or regular system time calls). In addition: * Add PASS_BY_REF flag with backwards compatibility to avoid bloating the signature of get()/getMulti() with the new tombstone information needed for the above changes. * Avoid confusing pass-by-reference in getInterimValue() and fix use of incorrect $asOf parameter. * Move some more logic into setInterimValue(). * Update some comments regarding broadcasted operations that were not true for the currently assumed mcrouter setup. * Rename $cValue => $curValue and $versioned => $needsVersion for better readability. Bug: T203786 Change-Id: I0eb3f9b697193d39a70dd3c0967311ad7e194f20
Diffstat (limited to 'tests/phpunit/includes/Storage/NameTableStoreTest.php')
-rw-r--r--tests/phpunit/includes/Storage/NameTableStoreTest.php25
1 files changed, 13 insertions, 12 deletions
diff --git a/tests/phpunit/includes/Storage/NameTableStoreTest.php b/tests/phpunit/includes/Storage/NameTableStoreTest.php
index 1517964471e9..4c2494a9637f 100644
--- a/tests/phpunit/includes/Storage/NameTableStoreTest.php
+++ b/tests/phpunit/includes/Storage/NameTableStoreTest.php
@@ -208,7 +208,7 @@ class NameTableStoreTest extends MediaWikiTestCase {
public function provideGetName() {
return [
- [ new HashBagOStuff(), 3, 3 ],
+ [ new HashBagOStuff(), 3, 2 ],
[ new EmptyBagOStuff(), 3, 3 ],
];
}
@@ -217,26 +217,27 @@ class NameTableStoreTest extends MediaWikiTestCase {
* @dataProvider provideGetName
*/
public function testGetName( $cacheBag, $insertCalls, $selectCalls ) {
+ // Check for operations to in-memory cache (IMC) and persistent cache (PC)
$store = $this->getNameTableSqlStore( $cacheBag, $insertCalls, $selectCalls );
// Get 1 ID and make sure getName returns correctly
- $fooId = $store->acquireId( 'foo' );
- $this->assertSame( 'foo', $store->getName( $fooId ) );
+ $fooId = $store->acquireId( 'foo' ); // regen PC, set IMC, update IMC, tombstone PC
+ $this->assertSame( 'foo', $store->getName( $fooId ) ); // use IMC
// Get another ID and make sure getName returns correctly
- $barId = $store->acquireId( 'bar' );
- $this->assertSame( 'bar', $store->getName( $barId ) );
+ $barId = $store->acquireId( 'bar' ); // update IMC, tombstone PC
+ $this->assertSame( 'bar', $store->getName( $barId ) ); // use IMC
// Blitz the cache and make sure it still returns
- TestingAccessWrapper::newFromObject( $store )->tableCache = null;
- $this->assertSame( 'foo', $store->getName( $fooId ) );
- $this->assertSame( 'bar', $store->getName( $barId ) );
+ TestingAccessWrapper::newFromObject( $store )->tableCache = null; // clear IMC
+ $this->assertSame( 'foo', $store->getName( $fooId ) ); // regen interim PC, set IMC
+ $this->assertSame( 'bar', $store->getName( $barId ) ); // use IMC
// Blitz the cache again and get another ID and make sure getName returns correctly
- TestingAccessWrapper::newFromObject( $store )->tableCache = null;
- $bazId = $store->acquireId( 'baz' );
- $this->assertSame( 'baz', $store->getName( $bazId ) );
- $this->assertSame( 'baz', $store->getName( $bazId ) );
+ TestingAccessWrapper::newFromObject( $store )->tableCache = null; // clear IMC
+ $bazId = $store->acquireId( 'baz' ); // set IMC using interim PC, update IMC, tombstone PC
+ $this->assertSame( 'baz', $store->getName( $bazId ) ); // uses IMC
+ $this->assertSame( 'baz', $store->getName( $bazId ) ); // uses IMC
}
public function testGetName_masterFallback() {