Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

changelog.d/13825.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Delete associated data from `event_failed_pull_attempts`, `insertion_events`, `insertion_event_extremities`, `insertion_event_extremities`, `insertion_event_extremities` when purging the room.

synapse/storage/databases/main/purge_events.py

+5
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ def _purge_room_txn(self, txn: LoggingTransaction, room_id: str) -> List[int]:
419419
"event_forward_extremities",
420420
"event_push_actions",
421421
"event_search",
422+
"event_failed_pull_attempts",
422423
"partial_state_events",
423424
"events",
424425
"federation_inbound_events_staging",
@@ -441,6 +442,10 @@ def _purge_room_txn(self, txn: LoggingTransaction, room_id: str) -> List[int]:
441442
"e2e_room_keys",
442443
"event_push_summary",
443444
"pusher_throttle",
445+
"insertion_events",
446+
"insertion_event_extremities",
447+
"insertion_event_edges",
448+
"batch_events",
444449
"room_account_data",
445450
"room_tags",
446451
# "rooms" happens last, to keep the foreign keys in the other tables

synapse/storage/schema/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@
8383
event_push_summary, receipts_linearized, and receipts_graph.
8484
- Add table `event_failed_pull_attempts` to keep track when we fail to pull
8585
events over federation.
86+
- Add indexes to various tables (`event_failed_pull_attempts`, `insertion_events`,
87+
`batch_events`) to make it easy to delete all associated rows when purging a room.
8688
"""
8789

8890

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* Copyright 2022 The Matrix.org Foundation C.I.C
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
-- Add index so we can easily purge all rows from a given `room_id`
17+
CREATE INDEX IF NOT EXISTS event_failed_pull_attempts_room_id ON event_failed_pull_attempts(room_id);
18+
19+
-- MSC2716 related tables:
20+
-- Add indexes so we can easily purge all rows from a given `room_id`
21+
CREATE INDEX IF NOT EXISTS insertion_events_room_id ON insertion_events(room_id);
22+
CREATE INDEX IF NOT EXISTS batch_events_room_id ON batch_events(room_id);

0 commit comments

Comments
 (0)