Skip to content

Conversation

@anoadragon453
Copy link
Member

Fixes #18738

Adds a cache to is_server_admin so this bit of code doesn't hammer the DB so hard:

# Force-enable server admin metadata because the only time an event with
# relevant metadata will be when the admin requested it via their admin
# client config account data. Also, it's "just" some `unsigned` fields, so
# shouldn't cause much in terms of problems to downstream consumers.
if config.requester is not None and await self._auth.is_server_admin(
config.requester
):
config = make_config_for_admin(config)

100000 was chosen as large homeservers such as matrix.org easily have that many users syncing within a reasonable time-frame.

Pull Request Checklist

  • Pull request is based on the develop branch
  • Pull request includes a changelog file. The entry should:
    • Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from EventStore to EventWorkerStore.".
    • Use markdown where necessary, mostly for code blocks.
    • End with either a period (.) or an exclamation mark (!).
    • Start with a capital letter.
    • Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry.
  • Code style is correct (run the linters)

And invalidate if it changes in the DB.
@anoadragon453 anoadragon453 changed the title Fix deactivation running off the main process (#18716) Improve performance of is_server_admin by adding a cache Jul 29, 2025
@anoadragon453 anoadragon453 marked this pull request as ready for review July 29, 2025 18:40
@anoadragon453 anoadragon453 requested a review from a team as a code owner July 29, 2025 18:40
@anoadragon453 anoadragon453 enabled auto-merge (squash) July 30, 2025 10:27
@anoadragon453 anoadragon453 merged commit 7ae7468 into release-v1.135 Jul 30, 2025
44 checks passed
@anoadragon453 anoadragon453 deleted the anoa/cache_is_server_admin branch July 30, 2025 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants