summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-09-12 12:54:38 +0100
committerErik Johnston <erik@matrix.org>2016-09-12 12:54:48 +0100
commit7cd6edb9470ed949b2c63317624dbc9e38950c95 (patch)
treef2a2439d53718ced095c002c55dc4823941f87c2
parentAdd back in query change (diff)
downloadsynapse-7cd6edb9470ed949b2c63317624dbc9e38950c95.tar.xz
Use register_background_index_update
-rw-r--r--synapse/storage/event_push_actions.py28
1 files changed, 4 insertions, 24 deletions
diff --git a/synapse/storage/event_push_actions.py b/synapse/storage/event_push_actions.py
index 40bfe754b5..7974a108ad 100644
--- a/synapse/storage/event_push_actions.py
+++ b/synapse/storage/event_push_actions.py
@@ -33,9 +33,11 @@ class EventPushActionsStore(SQLBaseStore):
         self.stream_ordering_month_ago = None
         super(EventPushActionsStore, self).__init__(hs)
 
-        self.register_background_update_handler(
+        self.register_background_index_update(
             self.EPA_HIGHLIGHT_INDEX,
-            self._background_index_epa_highlight,
+            index_name="event_push_actions_u_highlight",
+            table="event_push_actions",
+            columns=["user_id", "highlight", "stream_ordering"],
         )
 
     def _set_push_actions_for_event_and_users_txn(self, txn, event, tuples):
@@ -508,28 +510,6 @@ class EventPushActionsStore(SQLBaseStore):
 
         return range_end
 
-    @defer.inlineCallbacks
-    def _background_index_epa_highlight(self, progress, batch_size):
-        def reindex_txn(txn):
-            if isinstance(self.database_engine, PostgresEngine):
-                txn.execute(
-                    "CREATE INDEX CONCURRENTLY event_push_actions_u_highlight"
-                    " on event_push_actions(user_id, highlight, stream_ordering)"
-                )
-            else:
-                txn.execute(
-                    "CREATE INDEX event_push_actions_u_highlight"
-                    " on event_push_actions(user_id, highlight, stream_ordering)"
-                )
-
-        yield self.runInteraction(
-            self.EPA_HIGHLIGHT_INDEX, reindex_txn
-        )
-
-        yield self._end_background_update(self.EPA_HIGHLIGHT_INDEX)
-
-        defer.returnValue(1)
-
 
 def _action_has_highlight(actions):
     for action in actions: