Page MenuHomePhabricator

Create a per-user flag for enabling SUL3
Closed, ResolvedPublic

Description

When we opt a user into the SUL3 rollout, we'd like that to be consistent across wikis and authentication attempts. This is tricky because at the beginning of authentication, when we have to decide whether to start the SUL2 or SUL3 flow, we don't know who the user is. Getting it wrong is not the end of the world but we should minimize how often it happens.

We'll do that by relying on the UserName cookie (which is used by MediaWiki to pre-fill the username field, is set on login with 30 / 365 days expiry and does not get unset on logout):

  • add a GlobalPreferences hidden preference for preferring SUL2 over SUL3;
  • add some logic to SharedDomainUtils::isSul3Enabled() (as a new $wgCentralAuthEnableSul3 type) that checks the UserName cookie, looks up the global preference of the relevant user, and returns whether it is enabled;
  • add an in-process cache since isSul3Enabled() is called a lot;
  • add some helper method for setting the flag.

GlobalPreferences should be a soft dependency for CentralAuth, but can be a hard dependency for this feature (ie. wikis which don't have it just shouldn't set the relevant $wgCentralAuthEnableSul3 type).

Related Objects

Event Timeline

Change #1115497 had a related patch set uploaded (by ArielGlenn; author: ArielGlenn):

[mediawiki/extensions/CentralAuth@master] add configurations options and a global preference for the SUL3 rolllout

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

Change #1115782 had a related patch set uploaded (by ArielGlenn; author: ArielGlenn):

[integration/config@master] Tests for CentralAuth will need GlobalPreferences available

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

Change #1115782 merged by jenkins-bot:

[integration/config@master] Tests for CentralAuth will need GlobalPreferences available

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

Change #1118245 had a related patch set uploaded (by ArielGlenn; author: ArielGlenn):

[mediawiki/core@master] add a hook to assist with SUL3 rollout for login/signup

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

Change #1115497 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@master] Add configuration options and global preference for the SUL3 rolllout

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

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

[mediawiki/extensions/CentralAuth@wmf/1.44.0-wmf.16] Add configuration options and global preference for the SUL3 rolllout

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

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

[mediawiki/extensions/CentralAuth@wmf/1.44.0-wmf.17] Add configuration options and global preference for the SUL3 rolllout

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

Change #1120977 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@wmf/1.44.0-wmf.16] Add configuration options and global preference for the SUL3 rolllout

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

Change #1120978 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@wmf/1.44.0-wmf.17] Add configuration options and global preference for the SUL3 rolllout

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

Mentioned in SAL (#wikimedia-operations) [2025-02-19T15:29:02Z] <tgr@deploy2002> Started scap sync-world: Backport for [[gerrit:1120977|Add configuration options and global preference for the SUL3 rolllout (T384549 T377144 T384552 T384215)]], [[gerrit:1120978|Add configuration options and global preference for the SUL3 rolllout (T384549 T377144 T384552 T384215)]]

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

[mediawiki/extensions/CentralAuth@master] Make sure isSul3Enabled() is a boolean

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

Change #1121103 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@master] Make sure isSul3Enabled() is a boolean

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

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

[mediawiki/extensions/CentralAuth@wmf/1.44.0-wmf.16] Make sure isSul3Enabled() is a boolean

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

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

[mediawiki/extensions/CentralAuth@wmf/1.44.0-wmf.17] Make sure isSul3Enabled() is a boolean

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

Change #1121333 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@wmf/1.44.0-wmf.16] Make sure isSul3Enabled() is a boolean

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

Change #1121334 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@wmf/1.44.0-wmf.17] Make sure isSul3Enabled() is a boolean

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

This doesn't work in production and the log has Couldn't find a global ID for user <username> warnings, which makes me think we are running into T380500: CentralAuthUser returning outdated data after user creation.

Deployed some between 15:21-15:28 UTC. MySQL dashboards: s7 primary, a random s7 replica, s7 query rate, s7 aggregated. All seems normal so far.

wikiadmin2023@10.192.23.13(centralauth)> select count(*) from global_preferences where gp_property = 'centralauth-use-sul3';
+----------+
| count(*) |
+----------+
|        0 |
+----------+

After doing some live debugging, it seems CentralAuthUser is working correctly, but GlobalPreferencesFactory::getUserID() uses a replica CentralIdLookup so it doesn't see the freshly created central user record. After changing it to use READ_LATEST, it works as expected.

While looking into this, I discovered rEGPRb72fdbfce7fd: Call parent::execute() after SpecialGlobalPreferences checks (merged but not in production yet) which might also cause problems for our use of GlobalPreferencesFactory.

Change #1118245 abandoned by ArielGlenn:

[mediawiki/core@master] add a hook to assist with SUL3 rollout for login/signup

Reason:

in favour of I241872237a8b27bc4261e6231b55b068bd3ac428

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

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

[mediawiki/extensions/CentralAuth@master] Use UserOptionsManager for SUL3 rollout flag

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

Change #1122571 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@master] Use UserOptionsManager for SUL3 rollout flag

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

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

[mediawiki/extensions/CentralAuth@wmf/1.44.0-wmf.18] Use UserOptionsManager for SUL3 rollout flag

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

Change #1124783 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@wmf/1.44.0-wmf.18] Use UserOptionsManager for SUL3 rollout flag

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

Mentioned in SAL (#wikimedia-operations) [2025-03-05T16:19:50Z] <tgr@deploy2002> Started scap sync-world: Backport for [[gerrit:1124781|CentralAuthIdLookup: Reuse cached object on single-value lookup (T379909 T380500 T387106)]], [[gerrit:1124782|CentralAuthIdLookup: Use primary DB after writes (T379909 T380500)]], [[gerrit:1124783|Use UserOptionsManager for SUL3 rollout flag (T384549)]], [[gerrit:1124784|Make SUL3 global preference optional and simplify logic]], [[gerrit:1124785|Ad

Mentioned in SAL (#wikimedia-operations) [2025-03-05T16:22:50Z] <tgr@deploy2002> tgr: Backport for [[gerrit:1124781|CentralAuthIdLookup: Reuse cached object on single-value lookup (T379909 T380500 T387106)]], [[gerrit:1124782|CentralAuthIdLookup: Use primary DB after writes (T379909 T380500)]], [[gerrit:1124783|Use UserOptionsManager for SUL3 rollout flag (T384549)]], [[gerrit:1124784|Make SUL3 global preference optional and simplify logic]], [[gerrit:1124785|Add passive central do

Mentioned in SAL (#wikimedia-operations) [2025-03-05T16:54:47Z] <tgr@deploy2002> Finished scap sync-world: Backport for [[gerrit:1124781|CentralAuthIdLookup: Reuse cached object on single-value lookup (T379909 T380500 T387106)]], [[gerrit:1124782|CentralAuthIdLookup: Use primary DB after writes (T379909 T380500)]], [[gerrit:1124783|Use UserOptionsManager for SUL3 rollout flag (T384549)]], [[gerrit:1124784|Make SUL3 global preference optional and simplify logic]], [[gerrit:1124785|A

This seems to be working fine. I backported the UserOptionsManager patch so we don't have two different access mechanisms in production in parallel.