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

Fix get_max_topological_token to never return None #5221

Merged
merged 3 commits into from
Jun 6, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/5221.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix race when backfilling in rooms with worker mode.
12 changes: 11 additions & 1 deletion synapse/storage/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,18 @@ def get_topological_token_for_event(self, event_id):
)

def get_max_topological_token(self, room_id, stream_key):
"""Get the max topological token in a room that before given stream
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/that// ? or some better form of words?

ordering.

Args:
room_id (str)
stream_key (int)

Returns:
Deferred[int]
"""
sql = (
"SELECT max(topological_ordering) FROM events"
"SELECT coalesce(max(topological_ordering), 0) FROM events"
" WHERE room_id = ? AND stream_ordering < ?"
)
return self._execute(
Expand Down