summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
Diffstat (limited to 'synapse')
-rw-r--r--synapse/storage/stream.py11
-rw-r--r--synapse/util/caches/room_change_cache.py6
2 files changed, 12 insertions, 5 deletions
diff --git a/synapse/storage/stream.py b/synapse/storage/stream.py
index 67e7e6a76f..6a724193e1 100644
--- a/synapse/storage/stream.py
+++ b/synapse/storage/stream.py
@@ -199,12 +199,13 @@ class StreamStore(SQLBaseStore):
         if from_key == to_key:
             defer.returnValue(([], from_key))
 
-        has_changed = yield self._events_stream_cache.get_room_has_changed(
-            room_id, from_id
-        )
+        if from_id:
+            has_changed = yield self._events_stream_cache.get_room_has_changed(
+                room_id, from_id
+            )
 
-        if not has_changed:
-            defer.returnValue(([], from_key))
+            if not has_changed:
+                defer.returnValue(([], from_key))
 
         def f(txn):
             if from_id is not None:
diff --git a/synapse/util/caches/room_change_cache.py b/synapse/util/caches/room_change_cache.py
index eb2ab5f1e4..e8bfedd72f 100644
--- a/synapse/util/caches/room_change_cache.py
+++ b/synapse/util/caches/room_change_cache.py
@@ -39,6 +39,8 @@ class RoomStreamChangeCache(object):
         caches_by_name[self.name] = self._cache
 
     def get_room_has_changed(self, room_id, key):
+        assert type(key) is int
+
         if key <= self._earliest_known_key:
             return True
 
@@ -55,6 +57,8 @@ class RoomStreamChangeCache(object):
         """Returns subset of room ids that have had new things since the
         given key. If the key is too old it will just return the given list.
         """
+        assert type(key) is int
+
         if key > self._earliest_known_key:
             keys = self._cache.keys()
             i = keys.bisect_right(key)
@@ -73,6 +77,8 @@ class RoomStreamChangeCache(object):
     def room_has_changed(self, room_id, key):
         """Informs the cache that the room has been changed at the given key.
         """
+        assert type(key) is int
+
         if key > self._earliest_known_key:
             old_key = self._room_to_key.get(room_id, None)
             if old_key: