This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Delete unreferenced state groups during purge #4006
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
17d5857
Delete unreferened state groups during purge
erikjohnston 4917ff5
Add state_group index to event_to_state_groups
erikjohnston d9f3db5
Newsfile
erikjohnston 67a1e31
Fix up comments
erikjohnston 47a9da2
Batch process handling state groups
erikjohnston 056f099
Merge branch 'develop' of github.com:matrix-org/synapse into erikj/pu…
erikjohnston 67f7b9c
pep8
erikjohnston 03e634d
Merge branch 'develop' of github.com:matrix-org/synapse into erikj/pu…
erikjohnston b2399f6
Make SQL a bit cleaner
erikjohnston f4f223a
Don't make temporary list
erikjohnston 664b192
Fix set operations thinko
erikjohnston ad88460
Move _find_unreferenced_groups
erikjohnston File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Delete unreferenced state groups during history purge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
synapse/storage/schema/delta/52/add_event_to_state_group_index.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* Copyright 2018 New Vector Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
-- This is needed to efficiently check for unreferenced state groups during | ||
-- purge. Added events_to_state_group(state_group) index | ||
INSERT into background_updates (update_name, progress_json) | ||
VALUES ('event_to_state_groups_sg_index', '{}'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1257,6 +1257,7 @@ class StateStore(StateGroupWorkerStore, BackgroundUpdateStore): | |
STATE_GROUP_DEDUPLICATION_UPDATE_NAME = "state_group_state_deduplication" | ||
STATE_GROUP_INDEX_UPDATE_NAME = "state_group_state_type_index" | ||
CURRENT_STATE_INDEX_UPDATE_NAME = "current_state_members_idx" | ||
EVENT_STATE_GROUP_INDEX_UPDATE_NAME = "event_to_state_groups_sg_index" | ||
|
||
def __init__(self, db_conn, hs): | ||
super(StateStore, self).__init__(db_conn, hs) | ||
|
@@ -1275,6 +1276,12 @@ def __init__(self, db_conn, hs): | |
columns=["state_key"], | ||
where_clause="type='m.room.member'", | ||
) | ||
self.register_background_index_update( | ||
self.EVENT_STATE_GROUP_INDEX_UPDATE_NAME, | ||
index_name="event_to_state_groups_sg_index", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. worth remembering that we already have this on matrix.org, so would ideally not spend ages building another copy of the index. |
||
table="event_to_state_groups", | ||
columns=["state_group"], | ||
) | ||
|
||
def _store_event_state_mappings_txn(self, txn, events_and_contexts): | ||
state_groups = {} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a comment on why we are inheriting from
StateGroupWorkerStore
mightn't hurt; otoh perhaps it's obvious enough.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its obvious enough, especially since we use it in a fair few places and not just in purge history