Page MenuHomePhabricator

SUL3 prevents GrowthExperiments from accessing CommunityConfiguration on testwiki
Closed, ResolvedPublic

Description

Background

CommunityConfiguration exposes the MediaWikiConfigReader class, which can be used to access community configuration as if it was a Config object (which can be injected to anything that accepts one). For example, it is possible to get the value of GEMentorshipAutomaticEligibility by calling MediaWikiConfigReader::get( 'GEMentorshipAutomaticEligibility' ). The idea is to allow MediaWikiConfigReader to act as a drop-in replacement for GlobalVarConfig (which is the default implementation).

Unfortunately config variables can be registered across various configuration providers, and it is not possible to determine where CommunityConfiguration should expect a configuration variable based on its name. However, config names are globally unique across all of MediaWiki stack (they are usually exposed as PHP globals after all), CommunityConfiguration maintains a map of configuration names to configuration providers.

For example, a portion of this map could look like: "GEMentorshipAutomaticEligibility" => "Mentorship", which would inform CommunityConfiguration that GEMentorshipAutomaticEligibility is expected to be found in the Mentorship configuration provider (ConfigurationProviderFactory::newProvider( 'Mentorship' )->get( 'GEMentorshipAutomaticEligibility' ) should return the desired value). This way, CommunityConfiguration does not have to iterate across all available providers and query them all before it eventually finds one that matches (or not); instead, the lookup can be done in constant time regardless of the number of providers.

To ensure it is reused whenever possible, CommunityConfiguration caches this map in local server object cache (which is backed by APCu) with an expiry time of TTL_DAY. CommunityConfiguration never attempts to invalidate this cache; this is done, because we assume the only way how the map could change is through a code deployment (which causes a rolling restart of the cluster, which causes the local server object cache to be purged [as it does not survive server restarts]).

Problem

SUL3 breaks the assumption CommunityConfiguration has, and it allows the configuration => provider map (described above) to change without a code deployment. This is because WMF wikis have significantly tightened configuration when they are accessed via the auth.wikimedia.org domain (many extensions are disabled, many features are disabled, etc.). In other words, a wiki can have a different map when accessed via the auth domain and when accessed normally. This results in cache pollution within the CommunityConfiguration extension.

Specifically, the issue can be reproduced by following the steps below:

  1. Pick a non-k8s debug server (such as mwdebug2001).
  2. Restart PHP-FPM on that server (sudo -i /usr/local/sbin/restart-php7.4-fpm), to ensure the APCu cache is empty. This is not necessary strictly speaking, but it practically rules out other causes of the error (as you are likely to be the only one hitting that cache).
  3. Enable XWikimediaDebug for mwdebug2001.
  4. Ensure you are logged out at test.wikipedia.org.
  5. Login to any account with Growth features enabled (any new account will do): this will redirect you to auth.wikimedia.org (which is the tightened environment for SUL3 authentication) for the login form and then back to test.wikipedia.org (SUL3 kicks in)
    1. Incident-Reporting-System will query CommunityConfiguration (as part of the BeforePageDisplay hook).
    2. CommunityConfiguration will compute its map (as the cache is empty). It will not include any providers declared by GrowthExperiments, because GrowthExperiments is not enabled at auth.wikimedia.org (while both Incident-Reporting-System and MediaWiki-extensions-CommunityConfiguration are).
  6. At this point, CommunityConfiguration's cache is corrupted (GrowthExperiments is enabled, as you left the authentication domain, but it is not included in CommunityConfiguration's map).
  7. Open an editor of any page in the main space
    1. GrowthExperiments will query CommunityConfiguration
    2. CommunityConfiguration will reuse the map from step 5.B. It won't find the requested configuration variable there, and it will fail back to GlobalVarConfig.

For GrowthExperiments, this will result in the community configuration defined values not being respected. This is because we (still) have them in extension.json as well (as part of legacy CC code). Once we remove it (T367574), this would probably result in a fatal error instead (as GlobalVarConfig would not have the requested variable either).

Event Timeline

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

Thanks for identifying the issue in detail @Urbanecm_WMF!

In the narrowest sense, this will be fixed when we reenable GrowthExperiments on the authentication domain, which we'll need to do anyway because of T384236: [regression] Accounts created at test wikis are not receiving Growth features.

But more generally, maybe we should reconsider T373737: Disable irrelevant extensions on SUL3 login domain entirely. It seems like a maintenance nightmare in the long term - the cache issues it can introduce might be very hard to debug.

In the narrowest sense, this will be fixed when we reenable GrowthExperiments on the authentication domain

As of now, this issue can be only reproduced with GrowthExperiments. However, there are at least two other extensions that are likely to start using CommunityConfiguration relatively soon: namely, MediaWiki-extensions-Babel and Cite. Both are also disabled at the authentication domain. For Babel, the Growth team intends on releasing Community Configuration once we fix some bugs in the migration script. For Cite, WMDE is currently in the process of integrating CommunityConfiguration.

I think this should be resolved in a generic way (so that it does not fix just GrowthExperiments, but any other consumer of CommunityConfiguration).

@Tgr in relation to T384236#10503686, and as @Urbanecm_WMF has stated, is it possible to have a timeline when you will enable the GrowthExperiments extension on the SUL 3 domain?

@larissagaulia Is there a process for informing teams/maintainers likely to be affected by SUL3 to test and reach out to have their extensions enabled on the SUL 3 domain which would be better than having them finding out like us? Similar to how in the Temp Accounts project, there was a heads up/window period where teams could rework their extensions.

Change #1115369 had a related patch set uploaded (by Gergő Tisza; author: Gergő Tisza):

[operations/mediawiki-config@master] Do not disable extensions on SUL3 shared authentication domain

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

Change #1115369 merged by jenkins-bot:

[operations/mediawiki-config@master] Do not disable extensions on SUL3 shared authentication domain

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

Mentioned in SAL (#wikimedia-operations) [2025-01-30T21:10:42Z] <tgr@deploy2002> Started scap sync-world: Backport for [[gerrit:1115369|Do not disable extensions on SUL3 shared authentication domain (T373737 T384919 T384236)]]

Mentioned in SAL (#wikimedia-operations) [2025-01-30T21:13:29Z] <tgr@deploy2002> tgr: Backport for [[gerrit:1115369|Do not disable extensions on SUL3 shared authentication domain (T373737 T384919 T384236)]] synced to the testservers (https://wikitech.wikimedia.org/wiki/Mwdebug)

Mentioned in SAL (#wikimedia-operations) [2025-01-30T21:23:24Z] <tgr@deploy2002> Finished scap sync-world: Backport for [[gerrit:1115369|Do not disable extensions on SUL3 shared authentication domain (T373737 T384919 T384236)]] (duration: 12m 42s)

Pulling in to verify the fix works as intended.

Mentioned in SAL (#wikimedia-operations) [2025-01-31T13:05:05Z] <urbanecm> Restart mw-debug.codfw.pinkunicorn (verifying fix for T384919)

Urbanecm_WMF assigned this task to Tgr.

Similar to how in the Temp Accounts project, there was a heads up/window period where teams could rework their extensions.

Temporary accounts are a new concept introduced into MediaWiki core, that most extensions had to adapt to. SUL3 doesn't really change how MediaWiki behaves for the purposes of most extensions, even authentication-related extensions.

Making the set of enabled extensions variable for a given wiki broke some unstated assumptions that core and many extensions relied on, so that was clearly a bad idea. But with that removed, the changes are, hopefully, minimal, and if something does break, it's likely us who needs to rework something.