0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-12-17 21:13:53 +01:00

Add more logging for purging

Log the number of events we will be deleting at info.
This commit is contained in:
Richard van der Hoff 2017-05-11 12:06:28 +01:00
parent baafb85ba4
commit 114f290947

View file

@ -2033,6 +2033,8 @@ class EventsStore(SQLBaseStore):
400, "topological_ordering is greater than forward extremeties" 400, "topological_ordering is greater than forward extremeties"
) )
logger.debug("[purge] looking for events to delete")
txn.execute( txn.execute(
"SELECT event_id, state_key FROM events" "SELECT event_id, state_key FROM events"
" LEFT JOIN state_events USING (room_id, event_id)" " LEFT JOIN state_events USING (room_id, event_id)"
@ -2041,6 +2043,14 @@ class EventsStore(SQLBaseStore):
) )
event_rows = txn.fetchall() event_rows = txn.fetchall()
to_delete = [
(event_id,) for event_id, state_key in event_rows
if state_key is None and not self.hs.is_mine_id(event_id)
]
logger.info(
"[purge] found %i events before cutoff, of which %i are remote"
" non-state events to delete", len(event_rows), len(to_delete))
for event_id, state_key in event_rows: for event_id, state_key in event_rows:
txn.call_after(self._get_state_group_for_event.invalidate, (event_id,)) txn.call_after(self._get_state_group_for_event.invalidate, (event_id,))
@ -2091,6 +2101,7 @@ class EventsStore(SQLBaseStore):
) )
state_rows = txn.fetchall() state_rows = txn.fetchall()
logger.debug("[purge] found %i redundant state groups", len(state_rows))
# make a set of the redundant state groups, so that we can look them up # make a set of the redundant state groups, so that we can look them up
# efficiently # efficiently
@ -2184,10 +2195,6 @@ class EventsStore(SQLBaseStore):
) )
# Delete all remote non-state events # Delete all remote non-state events
to_delete = [
(event_id,) for event_id, state_key in event_rows
if state_key is None and not self.hs.is_mine_id(event_id)
]
for table in ( for table in (
"events", "events",
"event_json", "event_json",
@ -2203,7 +2210,7 @@ class EventsStore(SQLBaseStore):
"event_signatures", "event_signatures",
"rejections", "rejections",
): ):
logger.debug("[purge] removing non-state events from %s", table) logger.debug("[purge] removing remote non-state events from %s", table)
txn.executemany( txn.executemany(
"DELETE FROM %s WHERE event_id = ?" % (table,), "DELETE FROM %s WHERE event_id = ?" % (table,),
@ -2211,7 +2218,7 @@ class EventsStore(SQLBaseStore):
) )
# Mark all state and own events as outliers # Mark all state and own events as outliers
logger.debug("[purge] marking events as outliers") logger.debug("[purge] marking remaining events as outliers")
txn.executemany( txn.executemany(
"UPDATE events SET outlier = ?" "UPDATE events SET outlier = ?"
" WHERE event_id = ?", " WHERE event_id = ?",
@ -2221,7 +2228,7 @@ class EventsStore(SQLBaseStore):
] ]
) )
logger.debug("[purge] done") logger.info("[purge] done")
@defer.inlineCallbacks @defer.inlineCallbacks
def is_event_after(self, event_id1, event_id2): def is_event_after(self, event_id1, event_id2):