summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2018-09-13 12:48:10 +0100
committerErik Johnston <erik@matrix.org>2018-09-13 12:48:10 +0100
commitc857f5ef9b77b07179555a63973f11b8aa8c1752 (patch)
tree5fe95633078694b24d71089e89819cb344412f64 /synapse
parentMerge pull request #3846 from matrix-org/neilj/expose-registered-users (diff)
downloadsynapse-c857f5ef9b77b07179555a63973f11b8aa8c1752.tar.xz
Make purge history slightly faster
Don't pull out events that are outliers and won't be deleted, as nothing
should happen to them.
Diffstat (limited to 'synapse')
-rw-r--r--synapse/storage/events.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/synapse/storage/events.py b/synapse/storage/events.py
index 30ff87a4c4..1c8e01a47e 100644
--- a/synapse/storage/events.py
+++ b/synapse/storage/events.py
@@ -1930,15 +1930,22 @@ class EventsStore(EventFederationStore, EventsWorkerStore, BackgroundUpdateStore
         should_delete_params = ()
         if not delete_local_events:
             should_delete_expr += " AND event_id NOT LIKE ?"
-            should_delete_params += ("%:" + self.hs.hostname, )
+            should_delete_params += (
+                "%:" + self.hs.hostname,
+                "%:" + self.hs.hostname,
+            )
 
         should_delete_params += (room_id, token.topological)
 
+        # Note that we insert events that are outliers and aren't going to be
+        # deleted, as nothing will happen to them.
         txn.execute(
             "INSERT INTO events_to_purge"
             " SELECT event_id, %s"
             " FROM events AS e LEFT JOIN state_events USING (event_id)"
-            " WHERE e.room_id = ? AND topological_ordering < ?" % (
+            " WHERE (NOT outlier OR (%s)) AND e.room_id = ? AND topological_ordering < ?"
+            % (
+                should_delete_expr,
                 should_delete_expr,
             ),
             should_delete_params,