Page MenuHomePhabricator

Allow running rebuildLocalizationCache with Gadgets extension loaded and no DB connection
Closed, ResolvedPublic

Description

The maintenance script rebuildLocalizationCache.php shouldn't really need a DB connection in order to run.
However when run with the Gadgets extension loaded a getWithSetCallback call on WanCache calls Database::getCacheSetOptions which requires a database connection.

https://github.com/wikimedia/mediawiki-extensions-Gadgets/blob/master/includes/MediaWikiGadgetsDefinitionRepo.php#L105

With no DB connection this results in:

[0ecc9d2086ceee9fdbb9e20b] [no req]   Wikimedia\Rdbms\DBConnectionError from line 1213 of /var/www/html/includes/libs/rdbms/loadbalancer/LoadBalancer.php: Cannot access the database: No working replica DB server: Unknown error ()
Backtrace:
#0 /var/www/html/includes/libs/rdbms/loadbalancer/LoadBalancer.php(749): Wikimedia\Rdbms\LoadBalancer->reportConnectionError()
#1 /var/www/html/includes/GlobalFunctions.php(2637): Wikimedia\Rdbms\LoadBalancer->getConnection(boolean, array, boolean)
#2 /var/www/html/extensions/Gadgets/includes/MediaWikiGadgetsDefinitionRepo.php(105): wfGetDB(integer)
#3 /var/www/html/includes/libs/objectcache/WANObjectCache.php(1414): MediaWikiGadgetsDefinitionRepo->{closure}(boolean, integer, array, NULL)
#4 /var/www/html/includes/libs/objectcache/WANObjectCache.php(1275): WANObjectCache->doGetWithSetCallback(string, integer, Closure, array)
#5 /var/www/html/extensions/Gadgets/includes/MediaWikiGadgetsDefinitionRepo.php(115): WANObjectCache->getWithSetCallback(string, integer, Closure, array)
#6 /var/www/html/extensions/Gadgets/includes/MediaWikiGadgetsDefinitionRepo.php(31): MediaWikiGadgetsDefinitionRepo->loadGadgets()
#7 /var/www/html/extensions/Gadgets/includes/GadgetHooks.php(143): MediaWikiGadgetsDefinitionRepo->getGadgetIds()
#8 /var/www/html/includes/Hooks.php(174): GadgetHooks::registerModules(ResourceLoader)
#9 /var/www/html/includes/Hooks.php(202): Hooks::callHook(string, array, array, NULL)
#10 /var/www/html/includes/resourceloader/ResourceLoader.php(263): Hooks::run(string, array)
#11 /var/www/html/includes/ServiceWiring.php(444): ResourceLoader->__construct(GlobalVarConfig, WikWikiLogger)
#12 /var/www/html/includes/libs/services/ServiceContainer.php(430): Wikimedia\Services\ServiceContainer->{closure}(MediaWiki\MediaWikiServices)
#13 /var/www/html/includes/libs/services/ServiceContainer.php(414): Wikimedia\Services\ServiceContainer->createService(string)
#14 /var/www/html/includes/MediaWikiServices.php(771): Wikimedia\Services\ServiceContainer->getService(string)
#15 /var/www/html/includes/cache/localisation/LocalisationCache.php(1037): MediaWiki\MediaWikiServices->getResourceLoader()
#16 /var/www/html/includes/cache/localisation/LocalisationCacheBulkLoad.php(100): LocalisationCache->recache(string)
#17 /var/www/html/maintenance/rebuildLocalisationCache.php(162): LocalisationCacheBulkLoad->recache(string)
#18 /var/www/html/maintenance/rebuildLocalisationCache.php(122): RebuildLocalisationCache->doRebuild(array, LocalisationCacheBulkLoad, boolean)
#19 /var/www/html/maintenance/doMaintenance.php(99): RebuildLocalisationCache->execute()
#20 /var/www/html/maintenance/rebuildLocalisationCache.php(181): require_once(string)
#21 {main}

Event Timeline

I am running into similar issue when trying to build l10n files for containerized mediawiki. In my case the issue is that CommonSettings.php wants to contact an etcd server, so offline builds of l10n files cannot work (without hacks).

Change 667244 had a related patch set uploaded (by Ahmon Dancy; owner: Ahmon Dancy):
[operations/mediawiki-config@master] wmf-config/CommonSettings.php: Add MW_NO_ETCD handling

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

Change 667734 had a related patch set uploaded (by Dduvall; owner: Dduvall):
[mediawiki/core@master] maintenance: Skip setAgentAndTriggers for DB_NONE maintenance tasks

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

Change 667735 had a related patch set uploaded (by Dduvall; owner: Dduvall):
[mediawiki/core@master] maintenance: rebuildLocalisationCache should be DB_NONE if possible

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

Change 667906 had a related patch set uploaded (by Dduvall; owner: Dduvall):
[mediawiki/core@master] maintenance: Disable storage backend for DB_NONE tasks

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

Change 667734 merged by jenkins-bot:
[mediawiki/core@master] maintenance: Skip setAgentAndTriggers for DB_NONE maintenance tasks

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

Change 667906 merged by jenkins-bot:
[mediawiki/core@master] maintenance: Disable storage backend for DB_NONE tasks

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

Change 667735 merged by jenkins-bot:
[mediawiki/core@master] maintenance: rebuildLocalisationCache should be DB_NONE if possible

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

Change 668516 had a related patch set uploaded (by Dduvall; owner: Dduvall):
[mediawiki/core@wmf/1.36.0-wmf.33] maintenance: rebuildLocalisationCache should be DB_NONE if possible

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

Change 669790 had a related patch set uploaded (by Dduvall; owner: Dduvall):
[mediawiki/core@wmf/1.36.0-wmf.33] maintenance: Skip setAgentAndTriggers for DB_NONE maintenance tasks

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

Change 667244 merged by jenkins-bot:
[operations/mediawiki-config@master] wmf-config/CommonSettings.php: Add WMF_MAINTENANCE_OFFLINE handling

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

Change 669790 merged by jenkins-bot:
[mediawiki/core@wmf/1.36.0-wmf.33] maintenance: Skip setAgentAndTriggers for DB_NONE maintenance tasks

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

Change 668516 merged by jenkins-bot:
[mediawiki/core@wmf/1.36.0-wmf.33] maintenance: rebuildLocalisationCache should be DB_NONE if possible

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

dancy claimed this task.