summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2017-05-11 12:46:55 +0100
committerRichard van der Hoff <richard@matrix.org>2017-05-11 12:46:55 +0100
commit34194aaff7c86d57c6dabfb016b7597d999b2001 (patch)
tree83183237f8bf7edd191d8ab67eaae9d449d1cac5 /synapse/storage
parentAdd more logging for purging (diff)
downloadsynapse-34194aaff7c86d57c6dabfb016b7597d999b2001.tar.xz
Don't create event_search index on sqlite
... because the table is virtual
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/background_updates.py13
-rw-r--r--synapse/storage/events.py1
2 files changed, 11 insertions, 3 deletions
diff --git a/synapse/storage/background_updates.py b/synapse/storage/background_updates.py
index 12a8b8259c..7157fb1dfb 100644
--- a/synapse/storage/background_updates.py
+++ b/synapse/storage/background_updates.py
@@ -211,7 +211,8 @@ class BackgroundUpdateStore(SQLBaseStore):
 
     def register_background_index_update(self, update_name, index_name,
                                          table, columns, where_clause=None,
-                                         unique=False):
+                                         unique=False,
+                                         psql_only=False):
         """Helper for store classes to do a background index addition
 
         To use:
@@ -227,6 +228,9 @@ class BackgroundUpdateStore(SQLBaseStore):
             index_name (str): name of index to add
             table (str): table to add index to
             columns (list[str]): columns/expressions to include in index
+            unique (bool): true to make a UNIQUE index
+            psql_only: true to only create this index on psql databases (useful
+                for virtual sqlite tables)
         """
 
         def create_index_psql(conn):
@@ -288,13 +292,16 @@ class BackgroundUpdateStore(SQLBaseStore):
 
         if isinstance(self.database_engine, engines.PostgresEngine):
             runner = create_index_psql
+        elif psql_only:
+            runner = None
         else:
             runner = create_index_sqlite
 
         @defer.inlineCallbacks
         def updater(progress, batch_size):
-            logger.info("Adding index %s to %s", index_name, table)
-            yield self.runWithConnection(runner)
+            if runner is not None:
+                logger.info("Adding index %s to %s", index_name, table)
+                yield self.runWithConnection(runner)
             yield self._end_background_update(update_name)
             defer.returnValue(1)
 
diff --git a/synapse/storage/events.py b/synapse/storage/events.py
index 627e91a522..ea6879c619 100644
--- a/synapse/storage/events.py
+++ b/synapse/storage/events.py
@@ -216,6 +216,7 @@ class EventsStore(SQLBaseStore):
             table="event_search",
             columns=["event_id"],
             unique=True,
+            psql_only=True,
         )
 
         self._event_persist_queue = _EventPeristenceQueue()