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

Commit

Permalink
Merge pull request #2099 from matrix-org/erikj/deviceinbox_reduce
Browse files Browse the repository at this point in the history
Deduplicate new deviceinbox rows for replication
  • Loading branch information
erikjohnston authored Apr 5, 2017
2 parents a768867 + 9f26d3b commit b9caf4f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions synapse/storage/deviceinbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,23 +325,26 @@ def get_all_new_device_messages_txn(txn):
# we return.
upper_pos = min(current_pos, last_pos + limit)
sql = (
"SELECT stream_id, user_id"
"SELECT max(stream_id), user_id"
" FROM device_inbox"
" WHERE ? < stream_id AND stream_id <= ?"
" ORDER BY stream_id ASC"
" GROUP BY user_id"
)
txn.execute(sql, (last_pos, upper_pos))
rows = txn.fetchall()

sql = (
"SELECT stream_id, destination"
"SELECT max(stream_id), destination"
" FROM device_federation_outbox"
" WHERE ? < stream_id AND stream_id <= ?"
" ORDER BY stream_id ASC"
" GROUP BY destination"
)
txn.execute(sql, (last_pos, upper_pos))
rows.extend(txn)

# Order by ascending stream ordering
rows.sort()

return rows

return self.runInteraction(
Expand Down

0 comments on commit b9caf4f

Please sign in to comment.