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

Deduplicate new deviceinbox rows for replication #2099

Merged
merged 1 commit into from
Apr 5, 2017
Merged
Changes from all 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
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