Fix quarantined_media stream not being replicated - #20085
Conversation
The registration of `QuarantinedMediaStream` in `ReplicationCommandHandler._streams_to_replicate` was missed when the stream was added, so an instance configured as the quarantined_media_changes stream writer never sent RDATA/POSITION for it unless it was the main process. Also add the stream to the `instance_map` config validation. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
55deb63 to
709860a
Compare
|
|
||
| continue | ||
|
|
||
| if isinstance(stream, QuarantinedMediaStream): |
There was a problem hiding this comment.
does this need docs/development/synapse_architecture/streams.md#cheatsheet-for-creating-a-new-stream to be updated?
| must be routed directly to one of the workers configured as stream writer for the | ||
| `quarantined_media_changes` stream (which must also be able to run the media | ||
| repository, as these endpoints are only registered on media-capable workers): |
There was a problem hiding this comment.
The previous language matched what we did for other streams.
But this does seem more clear. Just noting that we should align all of the docs here.
| - will need an [ID generator](https://github.com/element-hq/synapse/blob/4367fb2d078c52959aeca0fe6874539c53e8360d/synapse/storage/databases/main/thread_subscriptions.py#L75) | ||
| - may need [writer configuration](https://github.com/element-hq/synapse/blob/4367fb2d078c52959aeca0fe6874539c53e8360d/synapse/config/workers.py#L177), if there isn't already an obvious source of configuration for which workers should be designated as writers to your new stream. | ||
| - if adding new writer configuration, add Docker-worker configuration, which lets us configure the writer worker in Complement tests: [[1]](https://github.com/element-hq/synapse/blob/4367fb2d078c52959aeca0fe6874539c53e8360d/docker/configure_workers_and_start.py#L331), [[2]](https://github.com/element-hq/synapse/blob/4367fb2d078c52959aeca0fe6874539c53e8360d/docker/configure_workers_and_start.py#L440) | ||
| - Ensure that it's been correctly added to `synapse/replication/tcp/handler.py` and it's `streams_to_replicate` attribute to ensure that changes are actually replicated. |
There was a problem hiding this comment.
We already have a point below about "consider whether it may make sense to introduce a handler" which seems like the relevant point here but just needs to be updated to link to what it's talking about and what considerations
| }, | ||
| ) | ||
|
|
||
| # Quarantining only records a change for media that exists. |
There was a problem hiding this comment.
This comment seems irrelevant.
We're not testing existing for non-existing media. And media_id1 doesn't correspond to existing media as far as I can tell
There was a problem hiding this comment.
Ohh, this is trying to say that we need to create some actual local media to quarintine.
| # Quarantining only records a change for media that exists. | |
| # Create some media that we can quarintine |
| - will need an [ID generator](https://github.com/element-hq/synapse/blob/4367fb2d078c52959aeca0fe6874539c53e8360d/synapse/storage/databases/main/thread_subscriptions.py#L75) | ||
| - may need [writer configuration](https://github.com/element-hq/synapse/blob/4367fb2d078c52959aeca0fe6874539c53e8360d/synapse/config/workers.py#L177), if there isn't already an obvious source of configuration for which workers should be designated as writers to your new stream. | ||
| - if adding new writer configuration, add Docker-worker configuration, which lets us configure the writer worker in Complement tests: [[1]](https://github.com/element-hq/synapse/blob/4367fb2d078c52959aeca0fe6874539c53e8360d/docker/configure_workers_and_start.py#L331), [[2]](https://github.com/element-hq/synapse/blob/4367fb2d078c52959aeca0fe6874539c53e8360d/docker/configure_workers_and_start.py#L440) | ||
| - Ensure that it's been correctly added to `synapse/replication/tcp/handler.py` and it's `streams_to_replicate` attribute to ensure that changes are actually replicated. |
There was a problem hiding this comment.
We could also link to the test added here as an example to sanity check things
…with more references (#20086) The [old link](https://github.com/element-hq/synapse/blob/4367fb2d078c52959aeca0fe6874539c53e8360d/synapse/config/workers.py#L177) only references `thread_subscriptions` once but in the latest state of the code with the [new link](https://github.com/element-hq/synapse/blob/62a4bc46203880dd5034483b0e84156d03a3a8c6/synapse/config/workers.py#L184-L187) there are 5 places in the file to look at. Spawning from seeing a few more changes in #20085 that were missed in #19558 and wondering why I didn't notice before. In fact, some of this clean-up for `thread_subscriptions` (the reference stream from the cheatsheet) wasn't updated until recently (this week) as part of #19556
The registration of
QuarantinedMediaStreaminReplicationCommandHandler._streams_to_replicatewas missed when the stream was added, so an instance configured as the quarantined_media_changes stream writer never sent RDATA/POSITION for it unless it was the main process.Also add the stream to the
instance_mapconfig validation.Stream was introduced in #19558
Fixes #20080