fix GIST->GIN switch
This commit is contained in:
parent
e79db0a673
commit
a66f489678
|
@ -13,5 +13,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
INSERT into background_updates (update_name, progress_json)
|
-- We no longer do this given we back it out again in schema 46
|
||||||
VALUES ('event_search_postgres_gist', '{}');
|
|
||||||
|
-- INSERT into background_updates (update_name, progress_json)
|
||||||
|
-- VALUES ('event_search_postgres_gist', '{}');
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
/* Copyright 2018 New Vector Ltd
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
INSERT into background_updates (update_name, progress_json)
|
||||||
|
VALUES ('event_search_postgres_gin', '{}');
|
|
@ -146,12 +146,12 @@ class SearchStore(BackgroundUpdateStore):
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _background_reindex_gin_search(self, progress, batch_size):
|
def _background_reindex_gin_search(self, progress, batch_size):
|
||||||
'''This handles old synapses which used GIST indexes; converting them
|
'''This handles old synapses which used GIST indexes, if any;
|
||||||
back to be GIN as per the actual schema. Otherwise it crashes out
|
converting them back to be GIN as per the actual schema.
|
||||||
as a NOOP
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def create_index(conn):
|
def create_index(conn):
|
||||||
|
try:
|
||||||
conn.rollback()
|
conn.rollback()
|
||||||
conn.set_session(autocommit=True)
|
conn.set_session(autocommit=True)
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
|
@ -164,6 +164,10 @@ class SearchStore(BackgroundUpdateStore):
|
||||||
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):
|
if isinstance(self.database_engine, PostgresEngine):
|
||||||
yield self.runWithConnection(create_index)
|
yield self.runWithConnection(create_index)
|
||||||
|
|
Loading…
Reference in New Issue