Page MenuHomePhabricator

Avoid lazyImportLocalNames() master writes on GET requests (Run a script to backfill them once for all)
Closed, ResolvedPublic

Description

This will avoid lots of DB updates that run on HTTP GET requests.

For example, just from viewing a page to get an array of the current user preferences, it seems to perform writes lazily (viewing Special:Preferences in this case).

  • Request ID: XW5kDApAMFIAAIi5KGEAAACL
  • Request URL: https://ru.wikipedia.org/w/index.php?title=Заглавная_страница&gettingStartedReturn=true
Expectation (masterConns <= 0) by MediaWiki::main not met (actual: 1):
[connect to 10.64.48.15 (centralauth)]

#0 /srv/mediawiki/php-1.34.0-wmf.20/includes/libs/rdbms/TransactionProfiler.php(186): Wikimedia\Rdbms\TransactionProfiler->reportExpectationViolated() …
#2 /srv/mediawiki/php-1.34.0-wmf.20/includes/libs/rdbms/loadbalancer/LoadBalancer.php(893): Wikimedia\Rdbms\LoadBalancer->getServerConnection() …
#5 /srv/mediawiki/php-1.34.0-wmf.20/extensions/CentralAuth/includes/CentralAuthUser.php(2230): CentralAuthUtils::getCentralDB()
#6 /srv/mediawiki/php-1.34.0-wmf.20/extensions/CentralAuth/includes/CentralAuthUser.php(2204): CentralAuthUser->importLocalNames()
#7 /srv/mediawiki/php-1.34.0-wmf.20/extensions/CentralAuth/includes/CentralAuthUser.php(2109): CentralAuthUser->lazyImportLocalNames()
#8 /srv/mediawiki/php-1.34.0-wmf.20/extensions/CentralAuth/includes/CentralAuthHooks.php(312): CentralAuthUser->listUnattached()
#9 /srv/mediawiki/php-1.34.0-wmf.20/includes/Hooks.php(174): CentralAuthHooks::onGetPreferences()
#10 /srv/mediawiki/php-1.34.0-wmf.20/includes/Hooks.php(202): Hooks::callHook()
#11 /srv/mediawiki/php-1.34.0-wmf.20/includes/preferences/DefaultPreferencesFactory.php(183): Hooks::run()
#12 /srv/mediawiki/php-1.34.0-wmf.20/extensions/GlobalPreferences/includes/GlobalPreferencesFactory.php(131): MediaWiki\Preferences\DefaultPreferencesFactory->getFormDescriptor()
#13 /srv/mediawiki/php-1.34.0-wmf.20/includes/preferences/DefaultPreferencesFactory.php(1498): GlobalPreferences\GlobalPreferencesFactory->getFormDescriptor()
#14 /srv/mediawiki/php-1.34.0-wmf.20/includes/specials/SpecialPreferences.php(113): MediaWiki\Preferences\DefaultPreferencesFactory->getForm()
#15 /srv/mediawiki/php-1.34.0-wmf.20/includes/specials/SpecialPreferences.php(90): SpecialPreferences->getFormObject()
#16 /srv/mediawiki/php-1.34.0-wmf.20/includes/specialpage/SpecialPage.php(573): SpecialPreferences->execute()
#17 /srv/mediawiki/php-1.34.0-wmf.20/includes/specialpage/SpecialPageFactory.php(582): SpecialPage->run()
#18 /srv/mediawiki/php-1.34.0-wmf.20/includes/MediaWiki.php(296): MediaWiki\Special\SpecialPageFactory->executePath()
#19 /srv/mediawiki/php-1.34.0-wmf.20/includes/MediaWiki.php(892): MediaWiki->performRequest()
#20 /srv/mediawiki/php-1.34.0-wmf.20/includes/MediaWiki.php(523): MediaWiki->main()
#21 /srv/mediawiki/php-1.34.0-wmf.20/index.php(42): MediaWiki->run()

Event Timeline

aaron triaged this task as Medium priority.Nov 11 2016, 1:29 AM
aaron added a subscriber: Legoktm.
aaron removed aaron as the assignee of this task.Aug 22 2017, 7:23 PM
CCicalese_WMF lowered the priority of this task from Medium to Low.Jan 30 2018, 2:10 AM
CCicalese_WMF moved this task from Inbox to Backlog on the MediaWiki-Platform-Team board.
Krinkle renamed this task from Run lazyImportLocalNames() on creation and run script to backfill them to Avoid lazyImportLocalNames() master writes on GET requests (Run a script to backfill them once for all).Sep 4 2019, 1:09 AM
Krinkle updated the task description. (Show Details)

Change 659222 had a related patch set uploaded (by Majavah; owner: Majavah):
[mediawiki/extensions/CentralAuth@master] Add a maintenance script to backfill local names

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

Majavah added a subscriber: Majavah.

Hi Performance team, could you please review the attached patch and help running the script on WMF beta and production clusters? Thanks!

Krinkle moved this task from Tracking/Watching to Inbox on the Platform Engineering board.
Krinkle added a subscriber: Krinkle.

Moving to PET inbox for consideration. We raised this as a concern and affects multi-dc but are not code owners for CentralAuth, we just observed the issue.

Change 659222 merged by jenkins-bot:
[mediawiki/extensions/CentralAuth@master] Add a maintenance script to backfill local names

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

The patch was merged (thanks!), now the new maintenance script needs to be ran on beta cluster and then production. Could someone advice on the process for that?

Gilles added a subscriber: Gilles.

@aaron will run the maintenance script on Beta and Production

Change 674163 had a related patch set uploaded (by Aaron Schulz; owner: Aaron Schulz):
[mediawiki/extensions/CentralAuth@master] Fix type error in importMissingLocalNames.php

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

Change 674163 merged by jenkins-bot:
[mediawiki/extensions/CentralAuth@master] Fix Type error in importMissingLocalNames.php

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

I finished running this on labs via:

mwscriptwikiset extensions/CentralAuth/maintenance/importMissingLocalNames.php all-labs.dblist

@Majavah, Do you need anything still from Platform team? It seems like the patches are merged. If not I will untag us.

@Majavah, Do you need anything still from Platform team? It seems like the patches are merged. If not I will untag us.

Hi, after the maintenance script has completed on production (not sure if still running, @aaron?) the lazy importing feature needs to be removed from CA.

Running it again since the screen is gone...

Change 683931 had a related patch set uploaded (by Majavah; author: Majavah):

[mediawiki/extensions/CentralAuth@master] Stop lazy importing local names

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

Change 683931 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@master] Stop lazy importing local names

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