File tree Expand file tree Collapse file tree
synapse/storage/databases/main Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ Use new receipts column to optimise receipt and push action SQL queries. Contributed by Nick @ Beeper (@fizzadar).
Original file line number Diff line number Diff line change @@ -734,9 +734,13 @@ def _insert_linearized_receipt_txn(
734734 thread_clause = "r.thread_id = ?"
735735 thread_args = (thread_id ,)
736736
737+ # If the receipt doesn't have a stream ordering it is because we
738+ # don't have the associated event, and so must be a remote receipt.
739+ # Hence it's safe to just allow new receipts to clobber it.
737740 sql = f"""
738741 SELECT r.event_stream_ordering, r.event_id FROM receipts_linearized AS r
739- WHERE r.room_id = ? AND r.receipt_type = ? AND r.user_id = ? AND { thread_clause }
742+ WHERE r.room_id = ? AND r.receipt_type = ? AND r.user_id = ?
743+ AND r.event_stream_ordering IS NOT NULL AND { thread_clause }
740744 """
741745 txn .execute (
742746 sql ,
You can’t perform that action at this time.
0 commit comments