summary refs log tree commit diff
path: root/synapse/handlers/message.py
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2020-10-20 17:51:35 +0100
committerAndrew Morgan <andrew@amorgan.xyz>2020-10-20 17:51:35 +0100
commit56722c69c5ac83a8d94661df307c01dc14439358 (patch)
treea6b0e55539b144f79942a30372dbc1a812af4096 /synapse/handlers/message.py
parentMerge commit 'abeab964d' into anoa/dinsic_release_1_21_x (diff)
parentRefactor `_get_e2e_device_keys_for_federation_query_txn` (#8225) (diff)
downloadsynapse-56722c69c5ac83a8d94661df307c01dc14439358.tar.xz
Merge commit '0d4f614fd' into anoa/dinsic_release_1_21_x
* commit '0d4f614fd':
  Refactor `_get_e2e_device_keys_for_federation_query_txn` (#8225)
  Add experimental support for sharding event persister. (#8170)
  Add /user/{user_id}/shared_rooms/ api (#7785)
  Do not try to store invalid data in the stats table (#8226)
  Convert the main methods run by the reactor to async. (#8213)
Diffstat (limited to 'synapse/handlers/message.py')
-rw-r--r--synapse/handlers/message.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py

index 6ab6ab2c34..aa362dade0 100644 --- a/synapse/handlers/message.py +++ b/synapse/handlers/message.py
@@ -377,9 +377,8 @@ class EventCreationHandler(object): self.notifier = hs.get_notifier() self.config = hs.config self.require_membership_for_aliases = hs.config.require_membership_for_aliases - self._is_event_writer = ( - self.config.worker.writers.events == hs.get_instance_name() - ) + self._events_shard_config = self.config.worker.events_shard_config + self._instance_name = hs.get_instance_name() self.room_invite_state_types = self.hs.config.room_invite_state_types @@ -907,9 +906,10 @@ class EventCreationHandler(object): try: # If we're a worker we need to hit out to the master. - if not self._is_event_writer: + writer_instance = self._events_shard_config.get_instance(event.room_id) + if writer_instance != self._instance_name: result = await self.send_event( - instance_name=self.config.worker.writers.events, + instance_name=writer_instance, event_id=event.event_id, store=self.store, requester=requester, @@ -977,7 +977,9 @@ class EventCreationHandler(object): This should only be run on the instance in charge of persisting events. """ - assert self._is_event_writer + assert self._events_shard_config.should_handle( + self._instance_name, event.room_id + ) if ratelimit: # We check if this is a room admin redacting an event so that we