mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-12-24 03:59:22 -05:00
Reindex state_groups_state after pruning
This commit is contained in:
parent
caa22334b3
commit
5beda10bbd
@ -133,10 +133,12 @@ class BackgroundUpdateStore(SQLBaseStore):
|
|||||||
updates = yield self._simple_select_list(
|
updates = yield self._simple_select_list(
|
||||||
"background_updates",
|
"background_updates",
|
||||||
keyvalues=None,
|
keyvalues=None,
|
||||||
retcols=("update_name",),
|
retcols=("update_name", "depends_on"),
|
||||||
)
|
)
|
||||||
|
in_flight = set(update["update_name"] for update in updates)
|
||||||
for update in updates:
|
for update in updates:
|
||||||
self._background_update_queue.append(update['update_name'])
|
if update["depends_on"] not in in_flight:
|
||||||
|
self._background_update_queue.append(update['update_name'])
|
||||||
|
|
||||||
if not self._background_update_queue:
|
if not self._background_update_queue:
|
||||||
# no work left to do
|
# no work left to do
|
||||||
|
@ -48,6 +48,7 @@ class StateStore(SQLBaseStore):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
STATE_GROUP_DEDUPLICATION_UPDATE_NAME = "state_group_state_deduplication"
|
STATE_GROUP_DEDUPLICATION_UPDATE_NAME = "state_group_state_deduplication"
|
||||||
|
STATE_GROUP_INDEX_UPDATE_NAME = "state_group_state_type_index"
|
||||||
|
|
||||||
def __init__(self, hs):
|
def __init__(self, hs):
|
||||||
super(StateStore, self).__init__(hs)
|
super(StateStore, self).__init__(hs)
|
||||||
@ -55,6 +56,10 @@ class StateStore(SQLBaseStore):
|
|||||||
self.STATE_GROUP_DEDUPLICATION_UPDATE_NAME,
|
self.STATE_GROUP_DEDUPLICATION_UPDATE_NAME,
|
||||||
self._background_deduplicate_state,
|
self._background_deduplicate_state,
|
||||||
)
|
)
|
||||||
|
self.register_background_update_handler(
|
||||||
|
self.STATE_GROUP_INDEX_UPDATE_NAME,
|
||||||
|
self._background_index_state,
|
||||||
|
)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def get_state_groups_ids(self, room_id, event_ids):
|
def get_state_groups_ids(self, room_id, event_ids):
|
||||||
@ -793,3 +798,31 @@ class StateStore(SQLBaseStore):
|
|||||||
yield self._end_background_update(self.STATE_GROUP_DEDUPLICATION_UPDATE_NAME)
|
yield self._end_background_update(self.STATE_GROUP_DEDUPLICATION_UPDATE_NAME)
|
||||||
|
|
||||||
defer.returnValue(result * BATCH_SIZE_SCALE_FACTOR)
|
defer.returnValue(result * BATCH_SIZE_SCALE_FACTOR)
|
||||||
|
|
||||||
|
@defer.inlineCallbacks
|
||||||
|
def _background_index_state(self, progress, batch_size):
|
||||||
|
def reindex_txn(txn):
|
||||||
|
if isinstance(self.database_engine, PostgresEngine):
|
||||||
|
txn.execute(
|
||||||
|
"CREATE INDEX state_groups_state_type_idx"
|
||||||
|
" ON state_groups_state(state_group, type, state_key)"
|
||||||
|
)
|
||||||
|
txn.execute(
|
||||||
|
"DROP INDEX IF EXISTS state_groups_state_id"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
txn.execute(
|
||||||
|
"CREATE INDEX state_groups_state_type_idx"
|
||||||
|
" ON state_groups_state(state_group, type, state_key)"
|
||||||
|
)
|
||||||
|
txn.execute(
|
||||||
|
"DROP INDEX IF EXISTS state_groups_state_id"
|
||||||
|
)
|
||||||
|
|
||||||
|
yield self.runInteraction(
|
||||||
|
self.STATE_GROUP_INDEX_UPDATE_NAME, reindex_txn
|
||||||
|
)
|
||||||
|
|
||||||
|
yield self._end_background_update(self.STATE_GROUP_INDEX_UPDATE_NAME)
|
||||||
|
|
||||||
|
defer.returnValue(1)
|
||||||
|
Loading…
Reference in New Issue
Block a user