Page MenuHomePhabricator

Remove hack to avoid contributions db group from MessageCache::loadFromDB()
Closed, ResolvedPublic

Description

MessageCache::loadFromDB() has a hack (introduced in this change for T164666) to avoid querying one of WMF’s contributions replicas (by querying an api replica instead):

	private function loadFromDB( $code, $mode = null ) {
		// (T164666) The query here performs really poorly on WMF's
		// contributions replicas. We don't have a way to say "any group except
		// contributions", so for the moment let's specify 'api'.
		// @todo: Get rid of this hack.
		$dbr = wfGetDB( ( $mode === self::FOR_UPDATE ) ? DB_PRIMARY : DB_REPLICA, 'api' );

As far as I can see in eqiad.php, the contributions group no longer exists; it was apparently removed in T263127. Hopefully that means we can get rid of the hack. (But it would be a good idea to test the query on all the existing groups first, to make sure it doesn’t perform badly. The commit that introduced the hack mentions that the query only runs once per day per wiki, so if it performed badly, it may not be visible immediately after deployment.)

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Yeah, that should arrive to normal replicas now.

I tried a few versions of the query and it seems to perform very well, under a second I think. Something like:

# preparation
>>> $revQuery = mws()->getRevisionStore()->getQueryInfo( [ 'page' ] ); $revQuery['joins']['revision'] = $revQuery['joins']['page']; unset( $revQuery['joins']['page'] ); $revQuery['tables'] = array_merge( [ 'page' ], array_diff( $revQuery['tables'], [ 'page' ] ) );
# content language, default group
>>> wfGetDB(DB_REPLICA)->select( $revQuery['tables'], $revQuery['fields'], [ 'page_is_redirect' => 0, 'page_namespace' => 8, 'page_title NOT LIKE "%/%"', 'page_len <= 1024', 'page_latest = rev_id' ], 'lucas-test-T314493', [ 'STRAIGHT_JOIN' ], $revQuery['joins'] )
# /de, vslow
>>> wfGetDB(DB_REPLICA, ['vslow'])->select( $revQuery['tables'], $revQuery['fields'], [ 'page_is_redirect' => 0, 'page_namespace' => 8, 'page_title LIKE "%/de"', 'page_len <= 1024', 'page_latest = rev_id' ], 'lucas-test-T314493', [ 'STRAIGHT_JOIN' ], $revQuery['joins'] )

Change 820150 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/core@master] Revert "MessageCache: Avoid 'contributions' replicas"

https://gerrit.wikimedia.org/r/820150

@Lucas_Werkmeister_WMDE Which wikis was that on? The original task was about enwiki but it's worth checking metawiki (and commonswiki) as well, those would likely be more sensitive the the issue I suspect.

Change 820150 merged by jenkins-bot:

[mediawiki/core@master] Revert "MessageCache: Avoid 'contributions' replicas"

https://gerrit.wikimedia.org/r/820150

I tested enwiki and commonswiki yesterday; I’ve now checked metawiki as well and performance still seems fine for all four groups (none, api, vslow, dump) and both unsuffixed and /de pages (though one of the queries, unsuffixed on dump, was closer to two seconds than one second).