From 86572c63ed57679d49c2fcb4bb2238f3724645cd Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Tue, 17 Mar 2026 16:19:49 +0000 Subject: [PATCH] Constrain profile endpoint handling to `profile_updates` writer workers And update relevant documentation/integration test config. --- .../complement/conf/start_for_complement.sh | 3 +- docker/configure_workers_and_start.py | 10 +++++++ docs/upgrade.md | 28 +++++++++++++++++++ .../configuration/config_documentation.md | 2 ++ schema/synapse-config.schema.yaml | 3 ++ synapse/rest/client/profile.py | 17 ++++++++--- 6 files changed, 58 insertions(+), 5 deletions(-) diff --git a/docker/complement/conf/start_for_complement.sh b/docker/complement/conf/start_for_complement.sh index da1b26a283..20c57d5c78 100755 --- a/docker/complement/conf/start_for_complement.sh +++ b/docker/complement/conf/start_for_complement.sh @@ -60,12 +60,13 @@ if [[ -n "$SYNAPSE_COMPLEMENT_USE_WORKERS" ]]; then federation_inbound, \ federation_reader, \ federation_sender, \ + profile_updates, \ synchrotron, \ client_reader, \ appservice, \ pusher, \ device_lists:2, \ - stream_writers=account_data+presence+receipts+to_device+typing" + stream_writers=account_data+presence+profile_updates+receipts+to_device+typing" fi log "Workers requested: $SYNAPSE_WORKER_TYPES" diff --git a/docker/configure_workers_and_start.py b/docker/configure_workers_and_start.py index ed15e8efef..1db2a8a779 100755 --- a/docker/configure_workers_and_start.py +++ b/docker/configure_workers_and_start.py @@ -308,6 +308,15 @@ WORKERS_CONFIG: dict[str, dict[str, Any]] = { "shared_extra_conf": {}, "worker_extra_conf": "", }, + "profile_updates": { + "app": "synapse.app.generic_worker", + "listener_resources": ["client", "replication"], + "endpoint_patterns": [ + "^/_matrix/client/(unstable/uk.tcpip.msc4133|api/v1|r0|v3|unstable)/profile/.*/" + ], + "shared_extra_conf": {}, + "worker_extra_conf": "", + }, "device_lists": { "app": "synapse.app.generic_worker", "listener_resources": ["client", "replication"], @@ -517,6 +526,7 @@ def add_worker_roles_to_shared_config( "typing", "push_rules", "thread_subscriptions", + "profile_updates", } # Worker-type specific sharding config. Now a single worker can fulfill multiple diff --git a/docs/upgrade.md b/docs/upgrade.md index 777e57c492..3c2fb7cb67 100644 --- a/docs/upgrade.md +++ b/docs/upgrade.md @@ -117,6 +117,34 @@ each upgrade are complete before moving on to the next upgrade, to avoid stacking them up. You can monitor the currently running background updates with [the Admin API](usage/administration/admin_api/background_updates.html#status). +# Upgrading to v1.151.0 + +## Profile Updates Stream Writer Workers + +This version of Synapse adds a new `profile_updates` writer stream. The +following endpoints may now only be handled by either the main process, or a +worker that is designed a "profile_updates" writer. If you are already routing +the following endpoints to a worker: + +``` +/_matrix/client/(api/v1|r0|v3)/profile//(?) +/_matrix/client/unstable/uk.tcpip.msc4133/profile//(?) +``` + +those worker(s) need to be marked as a stream writer for the `profile_updates` +stream in the shared config, using the +[`stream_writers`](https://element-hq.github.io/synapse/v1.151/usage/configuration/config_documentation.html#stream_writers) +config option: + +```yaml +stream_writers: + profile_updates: worker1 +``` + +as well as included in the +[`instance_map`](https://element-hq.github.io/synapse/v1.151/usage/configuration/config_documentation.html#instance_map) +config option. + # Upgrading to v1.150.0 ## Removal of the `systemd` pip extra diff --git a/docs/usage/configuration/config_documentation.md b/docs/usage/configuration/config_documentation.md index 1335def585..f80c007493 100644 --- a/docs/usage/configuration/config_documentation.md +++ b/docs/usage/configuration/config_documentation.md @@ -4475,6 +4475,8 @@ This setting has the following sub-options: * `device_lists` (string): Name of a worker assigned to the `device_lists` stream. +* `profile_updates` (string): Name of a worker assigned to the `profile_updates` stream. + Example configuration: ```yaml stream_writers: diff --git a/schema/synapse-config.schema.yaml b/schema/synapse-config.schema.yaml index 3a61a4c6fc..eea102d73e 100644 --- a/schema/synapse-config.schema.yaml +++ b/schema/synapse-config.schema.yaml @@ -5522,6 +5522,9 @@ properties: device_lists: type: string description: Name of a worker assigned to the `device_lists` stream. + profile_updates: + type: string + description: Name of a worker assigned to the `profile_updates` stream. default: {} examples: - events: worker1 diff --git a/synapse/rest/client/profile.py b/synapse/rest/client/profile.py index c2ec5b3611..d3655440e9 100644 --- a/synapse/rest/client/profile.py +++ b/synapse/rest/client/profile.py @@ -284,8 +284,17 @@ class UnstableProfileFieldRestServlet(ProfileFieldRestServlet): def register_servlets(hs: "HomeServer", http_server: HttpServer) -> None: - # The specific field endpoint *must* appear before the generic profile endpoint. - ProfileFieldRestServlet(hs).register(http_server) + # Updating user profiles requires the ability to write to the + # `profile_updates` stream. + if hs.get_instance_name() in hs.config.worker.writers.profile_updates: + # The specific field endpoint *must* appear before the generic profile + # endpoint (below). + + # TODO: Is it possible to still allow any generic_worker to handle the + # `GET` endpoint? + ProfileFieldRestServlet(hs).register(http_server) + + if hs.config.experimental.msc4133_enabled: + UnstableProfileFieldRestServlet(hs).register(http_server) + ProfileRestServlet(hs).register(http_server) - if hs.config.experimental.msc4133_enabled: - UnstableProfileFieldRestServlet(hs).register(http_server)