Without a `quarantined_media_changes` stream writer worker, the main process
is the writer for that stream and the reverse-proxy companion routes the
quarantine admin APIs to it. When media repository workers were enabled,
the main process had `enable_media_repo: false`, so it did not register
those APIs and returned 404.
Keep `enable_media_repo` enabled on the main process in that case.
The media repository's main background jobs remain assigned to the first
media repository worker via `media_instance_running_background_jobs`.
Since `homeserver.yaml` is shared with all workers, the other workers'
configuration files disable `enable_media_repo` again, so they don't load
the media repository (and run its retention tasks) needlessly.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Synapse requires `quarantined_media_changes` stream writers to be
media-capable, because the quarantine admin APIs are only registered on
workers that can load the media repository. All 5 quarantine endpoints
must be routed to such a writer.
Since this stream writer was added (5901f491f), quarantining has been broken
for setups with workers:
- the writer only served the `client` resource, so the one endpoint routed
to it (`/_synapse/admin/v1/quarantine_media/`) returned 404
- the other 4 endpoints were routed to media repository workers, which are
not writers for this stream, so Synapse failed an internal assertion
Make the writer media-capable (`enable_media_repo: true` and the `media`
listener resource) and route all 5 endpoints to it. The stream writer routes
are rendered before the media repository routes, so they take precedence.
This is skipped when an external media repository (matrix-media-repo) is
used, as quarantining Synapse's unused media repository would falsely
report success.
Ref: https://element-hq.github.io/synapse/latest/workers.html#the-quarantined_media_changes-stream
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Worker names are used as container hostnames, which are DNS labels limited
to 63 characters. With 10 or more stream writers listed before it, the
`quarantined_media_changes` writer got a name like
`matrix-synapse-worker-stream-writer-13-quarantined-media-changes`
(64 characters). Docker's embedded DNS refuses such names, so nginx in the
reverse-proxy companion logged `DNS error (1: Format error)` and could not
reach the worker.
Use `quarantined-media` in the worker name instead, and fail early if the
name of a worker which is reached over the network (web requests,
replication, metrics scraping) exceeds 63 characters.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`matrix_synapse_stream_writers` was only populated in `workers/init.yml`,
which is skipped when `matrix_synapse_workers_enabled_list` is defined
explicitly. Stream writer workers from such a list got an `instance_map`
entry and a replication listener, but Synapse was never told they write
anything, so the main process remained the writer for every stream.
This has been the case since stream writer support was added in 226c550ff.
Populate it in `inject_worker.yml` from the final worker list instead,
like `instance_map` and the other per-worker settings.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>