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

Commit

Permalink
Add fast path for replication events stream fetch (#16580)
Browse files Browse the repository at this point in the history
We can bail early if the from token is greater than or equal to the
current token.
  • Loading branch information
erikjohnston committed Oct 30, 2023
1 parent fdce83e commit 408c138
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/16580.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`.
6 changes: 6 additions & 0 deletions synapse/replication/tcp/streams/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ async def _update_function(
current_token: Token,
target_row_count: int,
) -> StreamUpdateResult:
# The events stream cannot be "reset", so its safe to return early if
# the from token is larger than the current token (the DB query will
# trivially return 0 rows anyway).
if from_token >= current_token:
return [], current_token, False

# the events stream merges together three separate sources:
# * new events
# * current_state changes
Expand Down

0 comments on commit 408c138

Please sign in to comment.