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

Commit

Permalink
Reduce amount of caches POSITIONS we send (#16561)
Browse files Browse the repository at this point in the history
Follow on from / actually correctly does #16557
  • Loading branch information
erikjohnston authored Oct 27, 2023
1 parent 89dbbd6 commit 5413cef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/16561.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +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`.
10 changes: 10 additions & 0 deletions synapse/replication/tcp/streams/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ async def get_updates(self) -> StreamUpdateResult:
and `limited` is whether there are more updates to fetch.
"""
current_token = self.current_token(self.local_instance_name)

# If the minimum current token for the local instance is less than or
# equal to the last thing we published, we know that there are no
# updates.
if self.last_token >= self.minimal_local_current_token():
self.last_token = current_token
return [], current_token, False

updates, current_token, limited = await self.get_updates_since(
self.local_instance_name, self.last_token, current_token
)
Expand Down Expand Up @@ -489,6 +497,8 @@ def current_token(self, instance_name: str) -> Token:
return self.store.get_cache_stream_token_for_writer(instance_name)

def minimal_local_current_token(self) -> Token:
if self.store._cache_id_gen:
return self.store._cache_id_gen.get_minimal_local_current_token()
return self.current_token(self.local_instance_name)


Expand Down

0 comments on commit 5413cef

Please sign in to comment.