diff options
author | Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> | 2020-06-01 10:53:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-01 10:53:06 +0100 |
commit | 2dc430d36ef793b38d6d79ec8db4ea60588df2ee (patch) | |
tree | a06c92743dea2ef6820c3714994c51537e6a7a43 /synapse/storage/data_stores | |
parent | Update OpenBSD installation instructions (#7587) (diff) | |
download | synapse-2dc430d36ef793b38d6d79ec8db4ea60588df2ee.tar.xz |
Use upsert when inserting read receipts (#7607)
Fixes #7469 Signed-off-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Diffstat (limited to 'synapse/storage/data_stores')
-rw-r--r-- | synapse/storage/data_stores/main/receipts.py | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/synapse/storage/data_stores/main/receipts.py b/synapse/storage/data_stores/main/receipts.py index 0d932a0672..cebdcd409f 100644 --- a/synapse/storage/data_stores/main/receipts.py +++ b/synapse/storage/data_stores/main/receipts.py @@ -391,7 +391,7 @@ class ReceiptsStore(ReceiptsWorkerStore): (user_id, room_id, receipt_type), ) - self.db.simple_delete_txn( + self.db.simple_upsert_txn( txn, table="receipts_linearized", keyvalues={ @@ -399,19 +399,14 @@ class ReceiptsStore(ReceiptsWorkerStore): "receipt_type": receipt_type, "user_id": user_id, }, - ) - - self.db.simple_insert_txn( - txn, - table="receipts_linearized", values={ "stream_id": stream_id, - "room_id": room_id, - "receipt_type": receipt_type, - "user_id": user_id, "event_id": event_id, "data": json.dumps(data), }, + # receipts_linearized has a unique constraint on + # (user_id, room_id, receipt_type), so no need to lock + lock=False, ) if receipt_type == "m.read" and stream_ordering is not None: |