Skip to content

Commit bc5dc69

Browse files
committed
Fix remote receipts for events we don't have
Introduced in #17032
1 parent 259442f commit bc5dc69

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

synapse/storage/databases/main/receipts.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff 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,

0 commit comments

Comments
 (0)