mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-12-16 08:54:19 -05:00
Use an upsert for receipts_graph
. (#13752)
Instead of a delete, then insert.
This was previously done for `receipts_linearized` in
2dc430d36e
(#7607).
This commit is contained in:
parent
c85c5ace52
commit
3d9f82efcb
1
changelog.d/13752.misc
Normal file
1
changelog.d/13752.misc
Normal file
@ -0,0 +1 @@
|
|||||||
|
User an additional database query when persisting receipts.
|
@ -812,7 +812,7 @@ class ReceiptsWorkerStore(SQLBaseStore):
|
|||||||
# FIXME: This shouldn't invalidate the whole cache
|
# FIXME: This shouldn't invalidate the whole cache
|
||||||
txn.call_after(self._get_linearized_receipts_for_room.invalidate, (room_id,))
|
txn.call_after(self._get_linearized_receipts_for_room.invalidate, (room_id,))
|
||||||
|
|
||||||
self.db_pool.simple_delete_txn(
|
self.db_pool.simple_upsert_txn(
|
||||||
txn,
|
txn,
|
||||||
table="receipts_graph",
|
table="receipts_graph",
|
||||||
keyvalues={
|
keyvalues={
|
||||||
@ -820,17 +820,13 @@ class ReceiptsWorkerStore(SQLBaseStore):
|
|||||||
"receipt_type": receipt_type,
|
"receipt_type": receipt_type,
|
||||||
"user_id": user_id,
|
"user_id": user_id,
|
||||||
},
|
},
|
||||||
)
|
|
||||||
self.db_pool.simple_insert_txn(
|
|
||||||
txn,
|
|
||||||
table="receipts_graph",
|
|
||||||
values={
|
values={
|
||||||
"room_id": room_id,
|
|
||||||
"receipt_type": receipt_type,
|
|
||||||
"user_id": user_id,
|
|
||||||
"event_ids": json_encoder.encode(event_ids),
|
"event_ids": json_encoder.encode(event_ids),
|
||||||
"data": json_encoder.encode(data),
|
"data": json_encoder.encode(data),
|
||||||
},
|
},
|
||||||
|
# receipts_graph has a unique constraint on
|
||||||
|
# (user_id, room_id, receipt_type), so no need to lock
|
||||||
|
lock=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user