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

Don't return unknown entities in get_entities_changed #3530

Merged
merged 3 commits into from
Jul 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added changelog.d/3530.misc
Empty file.
9 changes: 1 addition & 8 deletions synapse/util/caches/stream_change_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,12 @@ def get_entities_changed(self, entities, stream_pos):
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)
Expand Down
6 changes: 3 additions & 3 deletions tests/util/test_stream_change_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ def test_get_entities_changed(self):
)

# 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(
[
Expand All @@ -153,7 +153,7 @@ def test_get_entities_changed(self):
],
stream_pos=2,
),
set(["[email protected]", "[email protected]", "[email protected]"]),
set(["[email protected]", "[email protected]"]),
)

# Query all the entries, but before the first known point. We will get
Expand Down