diff options
author | Erik Johnston <erikj@element.io> | 2024-04-17 16:08:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-17 16:08:40 +0100 |
commit | 803f05f60caab050e68bfc022a6da3dac5a9a75f (patch) | |
tree | faa0bf6cd239afbc5f147a9ff56a86e689374ffa | |
parent | Support for MSC4108 via delegation (#17086) (diff) | |
download | synapse-803f05f60caab050e68bfc022a6da3dac5a9a75f.tar.xz |
Fix remote receipts for events we don't have (#17096)
Introduced in #17032
-rw-r--r-- | changelog.d/17096.misc | 1 | ||||
-rw-r--r-- | synapse/storage/databases/main/receipts.py | 6 |
2 files changed, 6 insertions, 1 deletions
diff --git a/changelog.d/17096.misc b/changelog.d/17096.misc new file mode 100644 index 0000000000..b03f6f42e5 --- /dev/null +++ b/changelog.d/17096.misc @@ -0,0 +1 @@ +Use new receipts column to optimise receipt and push action SQL queries. Contributed by Nick @ Beeper (@fizzadar). diff --git a/synapse/storage/databases/main/receipts.py b/synapse/storage/databases/main/receipts.py index 9660fc4699..13387a3839 100644 --- a/synapse/storage/databases/main/receipts.py +++ b/synapse/storage/databases/main/receipts.py @@ -734,9 +734,13 @@ class ReceiptsWorkerStore(SQLBaseStore): thread_clause = "r.thread_id = ?" thread_args = (thread_id,) + # If the receipt doesn't have a stream ordering it is because we + # don't have the associated event, and so must be a remote receipt. + # Hence it's safe to just allow new receipts to clobber it. sql = f""" SELECT r.event_stream_ordering, r.event_id FROM receipts_linearized AS r - WHERE r.room_id = ? AND r.receipt_type = ? AND r.user_id = ? AND {thread_clause} + WHERE r.room_id = ? AND r.receipt_type = ? AND r.user_id = ? + AND r.event_stream_ordering IS NOT NULL AND {thread_clause} """ txn.execute( sql, |