summary refs log tree commit diff
diff options
context:
space:
mode:
authorAmber Brown <hawkowl@atleastfornow.net>2018-07-17 13:44:46 +1000
committerGitHub <noreply@github.com>2018-07-17 13:44:46 +1000
commit3fe0938b76e0888a5147bbade99e120ea0505605 (patch)
tree3e61a930caf3ebd70f2741c28dba963c15e40cc7
parentMerge pull request #3540 from krombel/enforce_isort (diff)
parentFixup unit test (diff)
downloadsynapse-3fe0938b76e0888a5147bbade99e120ea0505605.tar.xz
Merge pull request #3530 from matrix-org/erikj/stream_cache
Don't return unknown entities in get_entities_changed
-rw-r--r--changelog.d/3530.misc0
-rw-r--r--synapse/util/caches/stream_change_cache.py9
-rw-r--r--tests/util/test_stream_change_cache.py6
3 files changed, 4 insertions, 11 deletions
diff --git a/changelog.d/3530.misc b/changelog.d/3530.misc
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/changelog.d/3530.misc
diff --git a/synapse/util/caches/stream_change_cache.py b/synapse/util/caches/stream_change_cache.py
index a1f8ff8f10..258655349b 100644
--- a/synapse/util/caches/stream_change_cache.py
+++ b/synapse/util/caches/stream_change_cache.py
@@ -74,19 +74,12 @@ class StreamChangeCache(object):
         assert type(stream_pos) is int
 
         if stream_pos >= self._earliest_known_stream_pos:
-            changed_entities = {
+            result = {
                 self._cache[k] for k in self._cache.islice(
                     start=self._cache.bisect_right(stream_pos),
                 )
             }
 
-            # we need to include entities which we don't know about, as well as
-            # those which are known to have changed since the stream pos.
-            result = {
-                e for e in entities
-                if e in changed_entities or e not in self._entity_to_key
-            }
-
             self.metrics.inc_hits()
         else:
             result = set(entities)
diff --git a/tests/util/test_stream_change_cache.py b/tests/util/test_stream_change_cache.py
index e3897c0d19..fc45baaaa0 100644
--- a/tests/util/test_stream_change_cache.py
+++ b/tests/util/test_stream_change_cache.py
@@ -141,8 +141,8 @@ class StreamChangeCacheTests(unittest.TestCase):
         )
 
         # Query all the entries mid-way through the stream, but include one
-        # that doesn't exist in it. We should get back the one that doesn't
-        # exist, too.
+        # that doesn't exist in it. We shouldn't get back the one that doesn't
+        # exist.
         self.assertEqual(
             cache.get_entities_changed(
                 [
@@ -153,7 +153,7 @@ class StreamChangeCacheTests(unittest.TestCase):
                 ],
                 stream_pos=2,
             ),
-            set(["bar@baz.net", "user@elsewhere.org", "not@here.website"]),
+            set(["bar@baz.net", "user@elsewhere.org"]),
         )
 
         # Query all the entries, but before the first known point. We will get