Skip to content

Commit 4bf3d6f

Browse files
committed
Cache invalidation keys must be str
1 parent 8488a9b commit 4bf3d6f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

synapse/storage/databases/main/cache.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
)
4444
from synapse.storage.engines import PostgresEngine
4545
from synapse.storage.util.id_generators import MultiWriterIdGenerator
46+
from synapse.types import StrCollection
4647
from synapse.util.caches.descriptors import CachedFunction
4748
from synapse.util.iterutils import batch_iter
4849

@@ -233,7 +234,7 @@ def process_replication_rows(
233234
)
234235

235236
room_id = row.keys[0]
236-
server_joined = row.keys.get(1, True)
237+
server_joined = bool(row.keys.get(1, "true"))
237238
self._invalidate_caches_for_room(room_id, server_joined)
238239
else:
239240
self._attempt_to_invalidate_cache(row.cache_func, row.keys)
@@ -429,7 +430,7 @@ def _invalidate_caches_for_room_and_stream(
429430
"""
430431

431432
self._send_invalidation_to_replication(
432-
txn, DELETE_ROOM_CACHE_NAME, [room_id, server_in_room]
433+
txn, DELETE_ROOM_CACHE_NAME, [room_id, "true" if server_in_room else ""]
433434
)
434435
txn.call_after(self._invalidate_caches_for_room, room_id, server_in_room)
435436

@@ -568,7 +569,7 @@ def _invalidate_state_caches_and_stream(
568569
for chunk in batch_iter(members_changed, 50):
569570
keys = itertools.chain([room_id], chunk)
570571
self._send_invalidation_to_replication(
571-
txn, CURRENT_STATE_CACHE_NAME, keys
572+
txn, CURRENT_STATE_CACHE_NAME, list(keys)
572573
)
573574
else:
574575
# if no members changed, we still need to invalidate the other caches.
@@ -587,7 +588,7 @@ async def send_invalidation_to_replication(
587588
)
588589

589590
def _send_invalidation_to_replication(
590-
self, txn: LoggingTransaction, cache_name: str, keys: Optional[Iterable[Any]]
591+
self, txn: LoggingTransaction, cache_name: str, keys: Optional[StrCollection]
591592
) -> None:
592593
"""Notifies replication that given cache has been invalidated.
593594

0 commit comments

Comments
 (0)