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

Commit

Permalink
Fix bug /sync returning 404 (#12729)
Browse files Browse the repository at this point in the history
* Fix bug /sync returning 404

Fixes #12571
  • Loading branch information
erikjohnston authored May 16, 2022
1 parent efcd899 commit 8689230
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions changelog.d/12729.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug introduced in Synapse 1.58.0 where `/sync` would fail if the most recent event in a room was rejected.
19 changes: 11 additions & 8 deletions synapse/storage/databases/main/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,14 +743,17 @@ async def get_room_event_before_stream_ordering(
"""

def _f(txn: LoggingTransaction) -> Optional[Tuple[int, int, str]]:
sql = (
"SELECT stream_ordering, topological_ordering, event_id"
" FROM events"
" WHERE room_id = ? AND stream_ordering <= ?"
" AND NOT outlier"
" ORDER BY stream_ordering DESC"
" LIMIT 1"
)
sql = """
SELECT stream_ordering, topological_ordering, event_id
FROM events
LEFT JOIN rejections USING (event_id)
WHERE room_id = ?
AND stream_ordering <= ?
AND NOT outlier
AND rejections.reason IS NULL
ORDER BY stream_ordering DESC
LIMIT 1
"""
txn.execute(sql, (room_id, stream_ordering))
return cast(Optional[Tuple[int, int, str]], txn.fetchone())

Expand Down

0 comments on commit 8689230

Please sign in to comment.