diff options
author | Matthew Hodgson <matthew@matrix.org> | 2018-01-09 16:55:51 +0000 |
---|---|---|
committer | Matthew Hodgson <matthew@matrix.org> | 2018-01-09 16:55:51 +0000 |
commit | a66f489678dc05fa89e6849405c37a9a390e62fc (patch) | |
tree | 404debd1e308eae3a4d7e1eccd9a1dc21d5e4589 /synapse/storage/search.py | |
parent | switch back from GIST to GIN indexes (diff) | |
download | synapse-a66f489678dc05fa89e6849405c37a9a390e62fc.tar.xz |
fix GIST->GIN switch
Diffstat (limited to '')
-rw-r--r-- | synapse/storage/search.py | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/synapse/storage/search.py b/synapse/storage/search.py index ba7141563e..d3e76b58d6 100644 --- a/synapse/storage/search.py +++ b/synapse/storage/search.py @@ -146,24 +146,28 @@ class SearchStore(BackgroundUpdateStore): @defer.inlineCallbacks def _background_reindex_gin_search(self, progress, batch_size): - '''This handles old synapses which used GIST indexes; converting them - back to be GIN as per the actual schema. Otherwise it crashes out - as a NOOP + '''This handles old synapses which used GIST indexes, if any; + converting them back to be GIN as per the actual schema. ''' def create_index(conn): - conn.rollback() - conn.set_session(autocommit=True) - c = conn.cursor() + try: + conn.rollback() + conn.set_session(autocommit=True) + c = conn.cursor() - c.execute( - "CREATE INDEX CONCURRENTLY event_search_fts_idx" - " ON event_search USING GIN (vector)" - ) + c.execute( + "CREATE INDEX CONCURRENTLY event_search_fts_idx" + " ON event_search USING GIN (vector)" + ) - c.execute("DROP INDEX event_search_fts_idx_gist") + c.execute("DROP INDEX event_search_fts_idx_gist") - conn.set_session(autocommit=False) + conn.set_session(autocommit=False) + except e: + logger.warn( + "Ignoring error %s when trying to switch from GIST to GIN" % (e,) + ) if isinstance(self.database_engine, PostgresEngine): yield self.runWithConnection(create_index) |