diff options
author | Erik Johnston <erik@matrix.org> | 2016-04-21 17:19:25 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2016-04-21 17:35:51 +0100 |
commit | 129e4034870956126daf520b41f74a51040ddbf9 (patch) | |
tree | 32fea5d8de5234cfd7c76f1c5f80873d24c0945f /synapse/storage/search.py | |
parent | Create index concurrently (diff) | |
download | synapse-129e4034870956126daf520b41f74a51040ddbf9.tar.xz |
Create index must be on a conn
Diffstat (limited to '')
-rw-r--r-- | synapse/storage/search.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/synapse/storage/search.py b/synapse/storage/search.py index 548e9eeaef..05641fb579 100644 --- a/synapse/storage/search.py +++ b/synapse/storage/search.py @@ -143,19 +143,26 @@ class SearchStore(BackgroundUpdateStore): rows_inserted = progress.get("rows_inserted", 0) have_added_index = progress['have_added_indexes'] - INSERT_CLUMP_SIZE = 1000 - - def reindex_search_txn(txn): - if not have_added_index: - txn.execute( + if not have_added_index: + def create_index(conn): + conn.rollback() + conn.set_session(autocommit=True) + c = conn.cursor() + c.execute( "CREATE INDEX CONCURRENTLY event_search_room_order ON event_search(" "room_id, origin_server_ts, stream_ordering)" ) - txn.execute( + c.execute( "CREATE INDEX CONCURRENTLY event_search_order ON event_search(" "origin_server_ts, stream_ordering)" ) + conn.set_session(autocommit=False) + + yield self.runWithConnection(create_index) + INSERT_CLUMP_SIZE = 1000 + + def reindex_search_txn(txn): sql = ( "SELECT stream_ordering, origin_server_ts, event_id FROM events" " INNER JOIN event_search USING (room_id, event_id)" |