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

Commit 408c138

Browse files
authored
Add fast path for replication events stream fetch (#16580)
We can bail early if the from token is greater than or equal to the current token.
1 parent fdce83e commit 408c138

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

changelog.d/16580.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/events.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ async def _update_function(
157157
current_token: Token,
158158
target_row_count: int,
159159
) -> StreamUpdateResult:
160+
# The events stream cannot be "reset", so its safe to return early if
161+
# the from token is larger than the current token (the DB query will
162+
# trivially return 0 rows anyway).
163+
if from_token >= current_token:
164+
return [], current_token, False
165+
160166
# the events stream merges together three separate sources:
161167
# * new events
162168
# * current_state changes

0 commit comments

Comments
 (0)