Skip to content
Snippets Groups Projects
Unverified Commit 2dc430d3 authored by Dagfinn Ilmari Mannsåker's avatar Dagfinn Ilmari Mannsåker Committed by GitHub
Browse files

Use upsert when inserting read receipts (#7607)


Fixes #7469

Signed-off-by: default avatarDagfinn Ilmari Mannsåker <ilmari@ilmari.org>
parent 91a7c5ff
No related branches found
No related tags found
No related merge requests found
Fix duplicate key violation when persisting read markers.
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment