element-hq / synapse

Synapse: Matrix homeserver written in Python/Twisted.
https://element-hq.github.io/synapse
GNU Affero General Public License v3.0
963 stars 109 forks source link

Handle multiple rows device inbox #17362

Closed erikjohnston closed 4 days ago

erikjohnston commented 5 days ago

Fix bug where we don't get new to-device from remote if they resent a message we've already persisted and have recorded in the DB twice.

device_federation_inbox table doesn't have a unique index, and so we can race and store an entry in there twice. If we do so then simple_select_one_txn will throw an error due to the query returning more than one row. We should add an unique index, but it doesn't really matter so lets just handle the case of multiple rows correctly for now.