diff --git a/synapse/replication/tcp/client.py b/synapse/replication/tcp/client.py index 43adef4400..3b0ff786c2 100644 --- a/synapse/replication/tcp/client.py +++ b/synapse/replication/tcp/client.py @@ -433,8 +433,11 @@ class FederationSenderHandler: # The entities are either user IDs (starting with '@') whose devices # have changed, or remote servers that we need to tell about # changes. - hosts = await self.store.get_destinations_for_device(token) - await self.federation_sender.send_device_messages(hosts, immediate=False) + if any(row.hosts_calcualted for row in rows): + hosts = await self.store.get_destinations_for_device(token) + await self.federation_sender.send_device_messages( + hosts, immediate=False + ) elif stream_name == ToDeviceStream.NAME: # The to_device stream includes stuff to be pushed to both local