From de6e2bc986170605c9500395008fd0129aaea0c1 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Wed, 25 May 2022 14:58:56 -0400 Subject: [PATCH 1/3] Avoid attempting to delete push actions for remote users. --- synapse/storage/databases/main/event_push_actions.py | 2 +- synapse/storage/databases/main/receipts.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/synapse/storage/databases/main/event_push_actions.py b/synapse/storage/databases/main/event_push_actions.py index b7c4c62222bd..b019979350e3 100644 --- a/synapse/storage/databases/main/event_push_actions.py +++ b/synapse/storage/databases/main/event_push_actions.py @@ -938,7 +938,7 @@ def _remove_old_push_actions_before_txn( users can still get a list of recent highlights. Args: - txn: The transcation + txn: The transaction room_id: Room ID to delete from user_id: user ID to delete for stream_ordering: The lowest stream ordering which will diff --git a/synapse/storage/databases/main/receipts.py b/synapse/storage/databases/main/receipts.py index d035969a3178..cfa4d4924d54 100644 --- a/synapse/storage/databases/main/receipts.py +++ b/synapse/storage/databases/main/receipts.py @@ -673,8 +673,11 @@ def insert_linearized_receipt_txn( lock=False, ) + # When updating a local users read receipt, remove any push actions + # which resulted from the receipt's event and all earlier events. if ( - receipt_type in (ReceiptTypes.READ, ReceiptTypes.READ_PRIVATE) + self.hs.is_mine_id(user_id) + and receipt_type in (ReceiptTypes.READ, ReceiptTypes.READ_PRIVATE) and stream_ordering is not None ): self._remove_old_push_actions_before_txn( # type: ignore[attr-defined] From 94d960ab567c574a509759ee19336be19263a900 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Wed, 25 May 2022 15:06:07 -0400 Subject: [PATCH 2/3] Newsfragment --- changelog.d/12879.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/12879.misc diff --git a/changelog.d/12879.misc b/changelog.d/12879.misc new file mode 100644 index 000000000000..24fa0d0de05f --- /dev/null +++ b/changelog.d/12879.misc @@ -0,0 +1 @@ +Avoid running queries which will never result in deletions. From 19d3a89b132e142f9203b5964c27e5046f59fc41 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Wed, 25 May 2022 15:39:33 -0400 Subject: [PATCH 3/3] More typos. --- synapse/federation/sender/per_destination_queue.py | 2 +- synapse/storage/persist_events.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/synapse/federation/sender/per_destination_queue.py b/synapse/federation/sender/per_destination_queue.py index d80f0ac5e8c3..8983b5a53d8a 100644 --- a/synapse/federation/sender/per_destination_queue.py +++ b/synapse/federation/sender/per_destination_queue.py @@ -223,7 +223,7 @@ def mark_new_data(self) -> None: """Marks that the destination has new data to send, without starting a new transaction. - If a transaction loop is already in progress then a new transcation will + If a transaction loop is already in progress then a new transaction will be attempted when the current one finishes. """ diff --git a/synapse/storage/persist_events.py b/synapse/storage/persist_events.py index 0fc282866bc5..a21dea91c852 100644 --- a/synapse/storage/persist_events.py +++ b/synapse/storage/persist_events.py @@ -313,7 +313,7 @@ async def persist_events( List of events persisted, the current position room stream position. The list of events persisted may not be the same as those passed in if they were deduplicated due to an event already existing that - matched the transcation ID; the existing event is returned in such + matched the transaction ID; the existing event is returned in such a case. """ partitioned: Dict[str, List[Tuple[EventBase, EventContext]]] = {}