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

Commit

Permalink
Undo ordering changes based on stream token in pagination txn
Browse files Browse the repository at this point in the history
  • Loading branch information
Fizzadar committed Apr 12, 2022
1 parent 9a78d14 commit 8e319cc
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions synapse/storage/databases/main/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -1171,14 +1171,6 @@ def _paginate_room_events_txn(
else:
order = "ASC"

# If we have only a stream token, order by stream_ordering, otherwise
# order by topologicial_ordering.
order_clause = """ORDER BY event.topological_ordering %(order)s, event.stream_ordering %(order)s"""
if from_token.topological is None:
order_clause = """ORDER BY event.stream_ordering %(order)s, event.topological_ordering %(order)s"""

order_clause = order_clause % {"order": order}

# The bounds for the stream tokens are complicated by the fact
# that we need to handle the instance_map part of the tokens. We do this
# by fetching all events between the min stream token and the maximum
Expand Down Expand Up @@ -1274,13 +1266,13 @@ def _paginate_room_events_txn(
FROM events AS event
%(join_clause)s
WHERE event.outlier = ? AND event.room_id = ? AND %(bounds)s
%(order_clause)s
LIMIT ?
ORDER BY event.topological_ordering %(order)s,
event.stream_ordering %(order)s LIMIT ?
""" % {
"select_keywords": select_keywords,
"join_clause": join_clause,
"bounds": bounds,
"order_clause": order_clause,
"order": order,
}

txn.execute(sql, args)
Expand Down

0 comments on commit 8e319cc

Please sign in to comment.