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

Commit 5413cef

Browse files
authored
Reduce amount of caches POSITIONS we send (#16561)
Follow on from / actually correctly does #16557
1 parent 89dbbd6 commit 5413cef

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

changelog.d/16561.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a long-standing, exceedingly rare edge case where the first event persisted by a new event persister worker might not be sent down `/sync`.

synapse/replication/tcp/streams/_base.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,14 @@ async def get_updates(self) -> StreamUpdateResult:
161161
and `limited` is whether there are more updates to fetch.
162162
"""
163163
current_token = self.current_token(self.local_instance_name)
164+
165+
# If the minimum current token for the local instance is less than or
166+
# equal to the last thing we published, we know that there are no
167+
# updates.
168+
if self.last_token >= self.minimal_local_current_token():
169+
self.last_token = current_token
170+
return [], current_token, False
171+
164172
updates, current_token, limited = await self.get_updates_since(
165173
self.local_instance_name, self.last_token, current_token
166174
)
@@ -489,6 +497,8 @@ def current_token(self, instance_name: str) -> Token:
489497
return self.store.get_cache_stream_token_for_writer(instance_name)
490498

491499
def minimal_local_current_token(self) -> Token:
500+
if self.store._cache_id_gen:
501+
return self.store._cache_id_gen.get_minimal_local_current_token()
492502
return self.current_token(self.local_instance_name)
493503

494504

0 commit comments

Comments
 (0)