forked from MirrorHub/synapse
add some logging to purge_history
This commit is contained in:
parent
a3648f84b2
commit
b64d312421
1 changed files with 21 additions and 4 deletions
|
@ -2033,6 +2033,8 @@ class EventsStore(SQLBaseStore):
|
|||
for event_id, state_key in event_rows:
|
||||
txn.call_after(self._get_state_group_for_event.invalidate, (event_id,))
|
||||
|
||||
logger.debug("[purge] Finding new backward extremities")
|
||||
|
||||
# We calculate the new entries for the backward extremeties by finding
|
||||
# all events that point to events that are to be purged
|
||||
txn.execute(
|
||||
|
@ -2045,6 +2047,8 @@ class EventsStore(SQLBaseStore):
|
|||
)
|
||||
new_backwards_extrems = txn.fetchall()
|
||||
|
||||
logger.debug("[purge] replacing backward extremities: %r", new_backwards_extrems)
|
||||
|
||||
txn.execute(
|
||||
"DELETE FROM event_backward_extremities WHERE room_id = ?",
|
||||
(room_id,)
|
||||
|
@ -2059,6 +2063,8 @@ class EventsStore(SQLBaseStore):
|
|||
]
|
||||
)
|
||||
|
||||
logger.debug("[purge] finding redundant state groups")
|
||||
|
||||
# Get all state groups that are only referenced by events that are
|
||||
# to be deleted.
|
||||
txn.execute(
|
||||
|
@ -2076,6 +2082,10 @@ class EventsStore(SQLBaseStore):
|
|||
state_rows = txn.fetchall()
|
||||
state_groups_to_delete = [sg for sg, in state_rows]
|
||||
|
||||
logger.debug(
|
||||
"[purge] finding state groups which depend on redundant state groups"
|
||||
)
|
||||
|
||||
# Now we get all the state groups that rely on these state groups
|
||||
new_state_edges = []
|
||||
chunks = [
|
||||
|
@ -2096,6 +2106,8 @@ class EventsStore(SQLBaseStore):
|
|||
# Now we turn the state groups that reference to-be-deleted state groups
|
||||
# to non delta versions.
|
||||
for new_state_edge in new_state_edges:
|
||||
logger.debug("[purge] de-delta-ing remaining state group %s",
|
||||
new_state_edge)
|
||||
curr_state = self._get_state_groups_from_groups_txn(
|
||||
txn, [new_state_edge], types=None
|
||||
)
|
||||
|
@ -2132,6 +2144,7 @@ class EventsStore(SQLBaseStore):
|
|||
],
|
||||
)
|
||||
|
||||
logger.debug("[purge] removing redundant state groups")
|
||||
txn.executemany(
|
||||
"DELETE FROM state_groups_state WHERE state_group = ?",
|
||||
state_rows
|
||||
|
@ -2140,12 +2153,15 @@ class EventsStore(SQLBaseStore):
|
|||
"DELETE FROM state_groups WHERE id = ?",
|
||||
state_rows
|
||||
)
|
||||
|
||||
# Delete all non-state
|
||||
logger.debug("[purge] removing events from event_to_state_groups")
|
||||
txn.executemany(
|
||||
"DELETE FROM event_to_state_groups WHERE event_id = ?",
|
||||
[(event_id,) for event_id, _ in event_rows]
|
||||
)
|
||||
|
||||
logger.debug("[purge] updating room_depth")
|
||||
txn.execute(
|
||||
"UPDATE room_depth SET min_depth = ? WHERE room_id = ?",
|
||||
(topological_ordering, room_id,)
|
||||
|
@ -2171,16 +2187,15 @@ class EventsStore(SQLBaseStore):
|
|||
"event_signatures",
|
||||
"rejections",
|
||||
):
|
||||
logger.debug("[purge] removing non-state events from %s", table)
|
||||
|
||||
txn.executemany(
|
||||
"DELETE FROM %s WHERE event_id = ?" % (table,),
|
||||
to_delete
|
||||
)
|
||||
|
||||
txn.executemany(
|
||||
"DELETE FROM events WHERE event_id = ?",
|
||||
to_delete
|
||||
)
|
||||
# Mark all state and own events as outliers
|
||||
logger.debug("[purge] marking events as outliers")
|
||||
txn.executemany(
|
||||
"UPDATE events SET outlier = ?"
|
||||
" WHERE event_id = ?",
|
||||
|
@ -2190,6 +2205,8 @@ class EventsStore(SQLBaseStore):
|
|||
]
|
||||
)
|
||||
|
||||
logger.debug("[purge] done")
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def is_event_after(self, event_id1, event_id2):
|
||||
"""Returns True if event_id1 is after event_id2 in the stream
|
||||
|
|
Loading…
Reference in a new issue