mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-14 18:43:53 +01:00
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.
This commit is contained in:
parent
fdce83ee60
commit
408c13801a
2 changed files with 7 additions and 0 deletions
1
changelog.d/16580.bugfix
Normal file
1
changelog.d/16580.bugfix
Normal file
|
@ -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`.
|
|
@ -157,6 +157,12 @@ class EventsStream(_StreamFromIdGen):
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue