Page MenuHomePhabricator

ContainerDisabledException in ServiceContainer due to failed installation with different language then English
Open, MediumPublicPRODUCTION ERROR

Description

I try to disabling cache, not resolved. What supposed to be do?

PHP version 7.2.26
I am trying to install v1.34.0 on MySQL.

Steps:

  • I upload all files to server.
  • I open install page /mw-config/index.php
  • I chose user langue as English
  • I chose wiki langue as Turkish
  • I chose no cache option.
  • Start installation
  • It is giving below error after creating tables.

Error stack below:

[Xgr0gANN3YI9fYR9javhPQAAABE] /ed/mw-config/index.php?page=Install Wikimedia\Services\ContainerDisabledException from line 419 of /home/mkysoft/public_html/ed/includes/libs/services/ServiceContainer.php: Container disabled!

Backtrace:

#0 /home/mkysoft/public_html/ed/includes/MediaWikiServices.php(722): Wikimedia\Services\ServiceContainer->getService(string)
#1 /home/mkysoft/public_html/ed/includes/ServiceWiring.php(325): MediaWiki\MediaWikiServices->getMainWANObjectCache()
#2 /home/mkysoft/public_html/ed/includes/cache/localisation/LocalisationCache.php(1049): Wikimedia\Services\ServiceContainer->{closure}()
#3 /home/mkysoft/public_html/ed/includes/cache/localisation/LocalisationCache.php(489): LocalisationCache->recache(string)
#4 /home/mkysoft/public_html/ed/includes/cache/localisation/LocalisationCache.php(406): LocalisationCache->initLanguage(string)
#5 /home/mkysoft/public_html/ed/includes/cache/localisation/LocalisationCache.php(325): LocalisationCache->loadSubitem(string, string, string)
#6 /home/mkysoft/public_html/ed/languages/Language.php(2545): LocalisationCache->getSubitem(string, string, string)
#7 /home/mkysoft/public_html/ed/includes/cache/MessageCache.php(970): Language->getMessage(string)
#8 /home/mkysoft/public_html/ed/includes/cache/MessageCache.php(928): MessageCache->getMessageForLang(LanguageTr, string, boolean, array)
#9 /home/mkysoft/public_html/ed/includes/cache/MessageCache.php(870): MessageCache->getMessageFromFallbackChain(LanguageTr, string, boolean)
#10 /home/mkysoft/public_html/ed/includes/language/Message.php(1297): MessageCache->get(string, boolean, LanguageTr)
#11 /home/mkysoft/public_html/ed/includes/language/Message.php(852): Message->fetchMessage()
#12 /home/mkysoft/public_html/ed/includes/language/Message.php(956): Message->toString(string)
#13 /home/mkysoft/public_html/ed/includes/user/User.php(982): Message->plain()
#14 /home/mkysoft/public_html/ed/includes/user/User.php(1170): User::isUsableName(string)
#15 /home/mkysoft/public_html/ed/includes/auth/TemporaryPasswordPrimaryAuthenticationProvider.php(201): User::getCanonicalName(string, string)
#16 /home/mkysoft/public_html/ed/includes/auth/AuthManager.php(2181): MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider->testUserExists(string, integer)
#17 /home/mkysoft/public_html/ed/includes/user/User.php(2681): MediaWiki\Auth\AuthManager->userExists(string)
#18 /home/mkysoft/public_html/ed/includes/user/User.php(2653): User->setPasswordInternal(string)
#19 /home/mkysoft/public_html/ed/includes/installer/Installer.php(1695): User->setPassword(string)
#20 /home/mkysoft/public_html/ed/includes/installer/Installer.php(1624): Installer->createSysop(MysqlInstaller)
#21 /home/mkysoft/public_html/ed/includes/installer/WebInstallerInstall.php(44): Installer->performInstallation(array, array)
#22 /home/mkysoft/public_html/ed/includes/installer/WebInstaller.php(270): WebInstallerInstall->execute()
#23 /home/mkysoft/public_html/ed/mw-config/index.php(80): WebInstaller->execute(array)
#24 /home/mkysoft/public_html/ed/mw-config/index.php(38): wfInstallerMain()
#25 {main}

Event Timeline

Masumrezarock100 changed the subtype of this task from "Task" to "Production Error".
Peachey88 added subscribers: Masumrezarock100, Peachey88.

@Masumrezarock100 The stack trace shows that it is a not a production wiki, that isn't a appropriate tag for the task.

I am no mediawiki developer, but normally one would ask for the Mediawiki version, what steps you were trying to accomplish (you seem to be running the installer?) and a copy of your configuration file.

@mkysoft: Can you please provide a complete list of all steps to reproduce the problem?

Hi @Aklapper ,

I found the problem. Turkish language fail on installation. I chose English and it is completed.

Thanks for support.

Hi, could you explain what "failed" means exactly, and which steps you performed? Wondering if some checks or error messages could be improved.

Aklapper renamed this task from I am getting ContainerDisabledException in ServiceContainer to ContainerDisabledException in ServiceContainer due to failed language installation.Dec 31 2019, 12:27 PM
mkysoft renamed this task from ContainerDisabledException in ServiceContainer due to failed language installation to ContainerDisabledException in ServiceContainer due to failed installation with different language then English.Dec 31 2019, 12:34 PM
mkysoft updated the task description. (Show Details)

I detailed steps.

My guess is there may be a dependency cycle in which the translation for the installer requires a service or string that is not yet installed. I believe similar errors happened in the past with non-standard installations, but we need the mw internationalization/dependency experts to confirm.

I was able to reproduce it quite consistently with the given steps- it happens on final setup, on creation of the sysop account, see screenshot:

Interestingly, this only happens with Turkish language, if I choose Spanish or Euskera, it works as intended, but if I restart the install and drop the database, it fails again. So must be Tr language specific.

My guess is there may be a dependency cycle in which the translation for the installer requires a service or string that is not yet installed. I believe similar errors happened in the past with non-standard installations, but we need the mw internationalization/dependency experts to confirm.

Possibly related to T231866: Circular dependency when creating service! ContentLanguage

daniel triaged this task as High priority.Jan 6 2020, 5:47 PM
daniel raised the priority of this task from High to Needs Triage.
daniel triaged this task as High priority.
daniel moved this task from Inbox to Backlog on the Platform Team Workboards (Clinic Duty Team) board.

Analysis:

  • A LocalisationCache object is created and cached in the initial MediaWikiServices instance. The LocalisationCache got a closure injected via the $clearStoreCallbacks parametre, that closure is bound to the MediaWikiServices instance. When recache() is called on LocalisationCache, this callback will in turn call $services->getResourceLoader()->getMessageBlobStore()->clear();
  • At some point, a Language object is created, which has a LocalisationCache instance assigned from the global instance of MediaWikiServices.
  • After setting up the database in the final phase of the installation, the installer will call DatabaseInstaller::enableLB(). This in turn will call MediaWikiServices::resetGlobalInstance(), invalidating the initial MediaWikiServices instance and replacing it with a fresh one, which now has access to the newly created database.
  • User::isUsableName uses the Language object created earlier, which is still cached in the static Language::$mLangObjCache array.
  • and causes it to call LocalisationCache->getSubitem(), which in turn triggers a call to LocalisationCache->recache(). Note that the LocalisationCache instance in used was create by the initial MediaWikiServices instance, which is now invalid.
  • The recache() invokes the callback originally injected into its constructor via the $clearStoreCallbacks parameter. This callback is bound to the initial MediaWikiServices instance, and will call getResourceLoader() on it.
  • The call to getResourceLoader() fails, because the initial MediaWikiServices instance is marked as destroyed.

Conceptually, the problem is that an object that is bound to a service instance, namely a Language object, is re-used after a call to MediaWikiServices::resetGlobalInstance().

Solution:
To fix this for 1.34, Language:clearCaches() needs to be called at the appropriate time by the installer, probably in enableLB().

It is possible that this is already fixed in 1.35, because Language::$mLangObjCache no longer exists. Instead, a LanguageFactory service is used, which would have been reset along with the rest of the services. Needs to be verified.

PS: I was not able to immediately reproduce this locally.

daniel removed daniel as the assignee of this task.

I made a patch for the 1_34 branch, https://gerrit.wikimedia.org/r/c/mediawiki/core/+/562510

Please try this patch and let me know if it works for you. Since I was unable to reproduce the problem locally, I can't test it myself.

Not the original reporter, but after applying the patch I can confirm the turkish installation went through correctly (twice):

Out of curiosity, do you know why specifically with Turkish and not with other (non-English) languages?

Edit: What is a good 1.35 version to verify the issue is not there? HEAD?

Not the original reporter, but after applying the patch I can confirm the turkish installation went through correctly (twice):

Thanks for testing!

Edit: What is a good 1.35 version to verify the issue is not there? HEAD?

Yes, head of master. If it's not a problem in master, we don't need to do anything.

Out of curiosity, do you know why specifically with Turkish and not with other (non-English) languages?

No idea - if I knew, I'd know how to reproduce it :)

Change 562510 had a related patch set uploaded (by Jforrester; owner: Daniel Kinzler):
[mediawiki/core@REL1_34] Installer: reset instance caches in enableLB().

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

Change 563241 had a related patch set uploaded (by Jforrester; owner: Daniel Kinzler):
[mediawiki/core@master] Installer: reset instance caches in enableLB().

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

Edit: What is a good 1.35 version to verify the issue is not there? HEAD?

Yes, head of master. If it's not a problem in master, we don't need to do anything.

1.35 DID break for me (338d458480d938e6e3d23f2e84cc6fe54d3a25c1):

[eb12ed75d3f98fea8b788139] /mediawiki-master/mw-config/index.php?page=Install Wikimedia\Services\ContainerDisabledException from line 411 of /var/www/html/mediawiki-master/includes/libs/services/ServiceContainer.php: Container disabled!

Backtrace:

#0 /var/www/html/mediawiki-master/includes/MediaWikiServices.php(785): Wikimedia\Services\ServiceContainer->getService(string)
#1 /var/www/html/mediawiki-master/includes/ServiceWiring.php(396): MediaWiki\MediaWikiServices->getMainWANObjectCache()
#2 /var/www/html/mediawiki-master/includes/cache/localisation/LocalisationCache.php(1051): Wikimedia\Services\ServiceContainer->{closure}()
#3 /var/www/html/mediawiki-master/includes/cache/localisation/LocalisationCache.php(489): LocalisationCache->recache(string)
#4 /var/www/html/mediawiki-master/includes/cache/localisation/LocalisationCache.php(406): LocalisationCache->initLanguage(string)
#5 /var/www/html/mediawiki-master/includes/cache/localisation/LocalisationCache.php(325): LocalisationCache->loadSubitem(string, string, string)
#6 /var/www/html/mediawiki-master/languages/Language.php(2582): LocalisationCache->getSubitem(string, string, string)
#7 /var/www/html/mediawiki-master/includes/cache/MessageCache.php(1004): Language->getMessage(string)
#8 /var/www/html/mediawiki-master/includes/cache/MessageCache.php(962): MessageCache->getMessageForLang(LanguageTr, string, boolean, array)
#9 /var/www/html/mediawiki-master/includes/cache/MessageCache.php(904): MessageCache->getMessageFromFallbackChain(LanguageTr, string, boolean)
#10 /var/www/html/mediawiki-master/includes/language/Message.php(1301): MessageCache->get(string, boolean, LanguageTr)
#11 /var/www/html/mediawiki-master/includes/language/Message.php(856): Message->fetchMessage()
#12 /var/www/html/mediawiki-master/includes/language/Message.php(960): Message->toString(string)
#13 /var/www/html/mediawiki-master/includes/user/User.php(1038): Message->plain()
#14 /var/www/html/mediawiki-master/includes/user/User.php(1226): User::isUsableName(string)
#15 /var/www/html/mediawiki-master/includes/auth/TemporaryPasswordPrimaryAuthenticationProvider.php(212): User::getCanonicalName(string, string)
#16 /var/www/html/mediawiki-master/includes/auth/AuthManager.php(2175): MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider->testUserExists(string, integer)
#17 /var/www/html/mediawiki-master/includes/user/User.php(2738): MediaWiki\Auth\AuthManager->userExists(string)
#18 /var/www/html/mediawiki-master/includes/user/User.php(2710): User->setPasswordInternal(string)
#19 /var/www/html/mediawiki-master/includes/installer/Installer.php(1683): User->setPassword(string)
#20 /var/www/html/mediawiki-master/includes/installer/Installer.php(1612): Installer->createSysop(MysqlInstaller)
#21 /var/www/html/mediawiki-master/includes/installer/WebInstallerInstall.php(44): Installer->performInstallation(array, array)
#22 /var/www/html/mediawiki-master/includes/installer/WebInstaller.php(270): WebInstallerInstall->execute()
#23 /var/www/html/mediawiki-master/mw-config/index.php(82): WebInstaller->execute(array)
#24 /var/www/html/mediawiki-master/mw-config/index.php(40): wfInstallerMain()
#25 {main}

Sadly, applying https://gerrit.wikimedia.org/r/c/mediawiki/core/+/563241 to current 1.35 gives me:

[97fb27a85925843003e5d8a3] /mediawiki-master/mw-config/index.php?page=Install MWException from line 393 of /var/www/html/mediawiki-master/includes/MediaWikiServices.php: resetServiceForTesting() must not be used outside unit tests.

Backtrace:

#0 /var/www/html/mediawiki-master/languages/Language.php(312): MediaWiki\MediaWikiServices->resetServiceForTesting(string)
#1 /var/www/html/mediawiki-master/includes/installer/DatabaseInstaller.php(378): Language::clearCaches()
#2 /var/www/html/mediawiki-master/includes/installer/DatabaseInstaller.php(239): DatabaseInstaller->enableLB()
#3 /var/www/html/mediawiki-master/includes/installer/DatabaseInstaller.php(251): DatabaseInstaller->stepApplySourceFile(string, string, boolean)
#4 /var/www/html/mediawiki-master/includes/installer/Installer.php(1612): DatabaseInstaller->createTables(MysqlInstaller)
#5 /var/www/html/mediawiki-master/includes/installer/WebInstallerInstall.php(44): Installer->performInstallation(array, array)
#6 /var/www/html/mediawiki-master/includes/installer/WebInstaller.php(270): WebInstallerInstall->execute()
#7 /var/www/html/mediawiki-master/mw-config/index.php(82): WebInstaller->execute(array)
#8 /var/www/html/mediawiki-master/mw-config/index.php(40): wfInstallerMain()
#9 {main}

On "Creating tables..." step.

Thanks for testing @jcrespo, I'll check it out!

Looks like this boils down to wfGetLangObj() returning $wgLang, which has a stale Language object. The same stale object would also be contained in the main RequestContext.

This usage of stale objects in the installer isn't new, what's new is that we now have a code path that triggers a sanity check that prevents access to stale services via MediaWikiServices. Disabling that check would get us back to the bad old days. The Right Thing (tm) would be to move all global instances into MediaWIki services (in this case, at least $wgLang and RequestContext::$instance). I'm trying to think of a "minimal viable fix" for the mean time, though...

Change 563423 had a related patch set uploaded (by Daniel Kinzler; owner: Daniel Kinzler):
[mediawiki/core@master] Installer: reset global instances after enabling LB

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

Change 563241 abandoned by Jforrester:
Installer: reset instance caches in enableLB().

Reason:
Apparently not needed.

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

daniel lowered the priority of this task from High to Medium.May 8 2020, 10:13 AM

Change 562510 abandoned by Umherirrender:
[mediawiki/core@REL1_34] Installer: reset instance caches in enableLB().

Reason:
release is end of life

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