Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Fix a cache-invalidation bug for worker-based deployments (#5920)
Browse files Browse the repository at this point in the history
  • Loading branch information
anoadragon453 committed Feb 21, 2020
2 parents 587b9c2 + 49ef8ec commit 41992a2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
1 change: 1 addition & 0 deletions changelog.d/5920.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a cache-invalidation bug for worker-based deployments.
24 changes: 16 additions & 8 deletions synapse/storage/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1392,14 +1392,22 @@ def _invalidate_state_caches_and_stream(self, txn, room_id, members_changed):
"""
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
Expand Down

0 comments on commit 41992a2

Please sign in to comment.