diff --git a/synapse/storage/registration.py b/synapse/storage/registration.py
index c9e11c3135..8b4554f6af 100644
--- a/synapse/storage/registration.py
+++ b/synapse/storage/registration.py
@@ -146,6 +146,7 @@ class RegistrationStore(RegistrationWorkerStore,
def __init__(self, db_conn, hs):
super(RegistrationStore, self).__init__(db_conn, hs)
+ self.hs = hs
self.clock = hs.get_clock()
self.register_background_index_update(
@@ -321,10 +322,12 @@ class RegistrationStore(RegistrationWorkerStore,
(user_id_obj.localpart, create_profile_with_displayname)
)
- self._invalidate_cache_and_stream(
- txn, self.get_user_by_id, (user_id,)
- )
- txn.call_after(self.is_guest.invalidate, (user_id,))
+ # Don't invalidate here, it will be done through replication to the worker.
+ if not self.hs.config.worker_app:
+ self._invalidate_cache_and_stream(
+ txn, self.get_user_by_id, (user_id,)
+ )
+ txn.call_after(self.is_guest.invalidate, (user_id,))
def get_users_by_id_case_insensitive(self, user_id):
"""Gets users that match user_id case insensitively.
|