summary refs log tree commit diff
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2020-02-21 11:32:54 +0000
committerAndrew Morgan <andrew@amorgan.xyz>2020-02-21 11:32:54 +0000
commit41992a2e0013ec1f8f4d4d7bf068b1d00523f3ca (patch)
tree8709b109744407b4a8d5b1998f05ade510a1cf44
parentMerge pull request #5914 from matrix-org/rei/admin_getadmin (diff)
parentFix a cache-invalidation bug for worker-based deployments (#5920) (diff)
downloadsynapse-41992a2e0013ec1f8f4d4d7bf068b1d00523f3ca.tar.xz
Fix a cache-invalidation bug for worker-based deployments (#5920)
-rw-r--r--changelog.d/5920.bugfix1
-rw-r--r--synapse/storage/_base.py24
2 files changed, 17 insertions, 8 deletions
diff --git a/changelog.d/5920.bugfix b/changelog.d/5920.bugfix
new file mode 100644

index 0000000000..e45eb0ffee --- /dev/null +++ b/changelog.d/5920.bugfix
@@ -0,0 +1 @@ +Fix a cache-invalidation bug for worker-based deployments. diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py
index 56a54267af..1ef5662c31 100644 --- a/synapse/storage/_base.py +++ b/synapse/storage/_base.py
@@ -1392,14 +1392,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