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

Commit

Permalink
Deduplicate new deviceinbox rows for replication
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjohnston committed Apr 4, 2017
1 parent a768867 commit 9f26d3b
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 9f26d3b

Please sign in to comment.