forked from MirrorHub/synapse
Use upsert when inserting read receipts (#7607)
Fixes #7469 Signed-off-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
This commit is contained in:
parent
91a7c5ff6d
commit
2dc430d36e
2 changed files with 5 additions and 9 deletions
1
changelog.d/7607.bugfix
Normal file
1
changelog.d/7607.bugfix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Fix duplicate key violation when persisting read markers.
|
|
@ -391,7 +391,7 @@ class ReceiptsStore(ReceiptsWorkerStore):
|
||||||
(user_id, room_id, receipt_type),
|
(user_id, room_id, receipt_type),
|
||||||
)
|
)
|
||||||
|
|
||||||
self.db.simple_delete_txn(
|
self.db.simple_upsert_txn(
|
||||||
txn,
|
txn,
|
||||||
table="receipts_linearized",
|
table="receipts_linearized",
|
||||||
keyvalues={
|
keyvalues={
|
||||||
|
@ -399,19 +399,14 @@ class ReceiptsStore(ReceiptsWorkerStore):
|
||||||
"receipt_type": receipt_type,
|
"receipt_type": receipt_type,
|
||||||
"user_id": user_id,
|
"user_id": user_id,
|
||||||
},
|
},
|
||||||
)
|
|
||||||
|
|
||||||
self.db.simple_insert_txn(
|
|
||||||
txn,
|
|
||||||
table="receipts_linearized",
|
|
||||||
values={
|
values={
|
||||||
"stream_id": stream_id,
|
"stream_id": stream_id,
|
||||||
"room_id": room_id,
|
|
||||||
"receipt_type": receipt_type,
|
|
||||||
"user_id": user_id,
|
|
||||||
"event_id": event_id,
|
"event_id": event_id,
|
||||||
"data": json.dumps(data),
|
"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:
|
if receipt_type == "m.read" and stream_ordering is not None:
|
||||||
|
|
Loading…
Reference in a new issue