diff options
author | Richard van der Hoff <1389908+richvdh@users.noreply.github.com> | 2019-08-28 10:18:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-28 10:18:16 +0100 |
commit | 49ef8ec3995db4d14e1b1367c9cd96ea231072f4 (patch) | |
tree | 671097e8cdebb335c9e6c6335539e64fc1297d50 /synapse | |
parent | Merge pull request #5914 from matrix-org/rei/admin_getadmin (diff) | |
download | synapse-49ef8ec3995db4d14e1b1367c9cd96ea231072f4.tar.xz |
Fix a cache-invalidation bug for worker-based deployments (#5920)
Some of the caches on worker processes were not being correctly invalidated when a room's state was changed in a way that did not affect the membership list of the room. We need to make sure we send out cache invalidations even when no memberships are changing.
Diffstat (limited to 'synapse')
-rw-r--r-- | synapse/storage/_base.py | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py index 489ce82fae..abe16334ec 100644 --- a/synapse/storage/_base.py +++ b/synapse/storage/_base.py @@ -1395,14 +1395,22 @@ class SQLBaseStore(object): """ txn.call_after(self._invalidate_state_caches, room_id, members_changed) - # We need to be careful that the size of the `members_changed` list - # isn't so large that it causes problems sending over replication, so we - # send them in chunks. - # Max line length is 16K, and max user ID length is 255, so 50 should - # be safe. - for chunk in batch_iter(members_changed, 50): - keys = itertools.chain([room_id], chunk) - self._send_invalidation_to_replication(txn, _CURRENT_STATE_CACHE_NAME, keys) + if members_changed: + # We need to be careful that the size of the `members_changed` list + # isn't so large that it causes problems sending over replication, so we + # send them in chunks. + # Max line length is 16K, and max user ID length is 255, so 50 should + # be safe. + for chunk in batch_iter(members_changed, 50): + keys = itertools.chain([room_id], chunk) + self._send_invalidation_to_replication( + txn, _CURRENT_STATE_CACHE_NAME, keys + ) + else: + # if no members changed, we still need to invalidate the other caches. + self._send_invalidation_to_replication( + txn, _CURRENT_STATE_CACHE_NAME, [room_id] + ) def _invalidate_state_caches(self, room_id, members_changed): """Invalidates caches that are based on the current state, but does |