Page MenuHomePhabricator

CentralAuthIdLookup should use a cache
Closed, ResolvedPublic

Description

CentralAuthIdLookup (CentralAuth's implementation of the CentralIdLookup service) does a DB query every time it's invoked, and it can be invoked many times per request. It should have an in-process cache at the minumum, and probably an object / WAN cache too. CentralAuthUser already has both, and already deals with invalidation, so ideally it should be integrated with that, although for batch lookups that doesn't seem trivial.

Event Timeline

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

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

[mediawiki/extensions/CentralAuth@master] [WIP] CentralAuthIdLookup: Reuse cached object on single-value lookup

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

Change #1121784 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@master] CentralAuthIdLookup: Reuse cached object on single-value lookup

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

matmarex subscribed.

For the record, CentralAuthUserArrayFromResult also functions as a kind of cache, but it weakens the cohesion of core user handling logic, and should probably be handled in a different way, which might overlap with the problem that CentralAuthIdLookup batch queries are still uncached (although I don't think CentralAuthIdLookup batch queries are used much). There was some related discussion on gerrit 1122521 and gerrit 1122283.

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

[mediawiki/extensions/CentralAuth@wmf/1.44.0-wmf.18] CentralAuthIdLookup: Reuse cached object on single-value lookup

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

Change #1124781 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@wmf/1.44.0-wmf.18] CentralAuthIdLookup: Reuse cached object on single-value lookup

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

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