mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-12-20 15:04:20 -05:00
Fix reindex
This commit is contained in:
parent
d5ae1f1291
commit
00f51493f5
@ -819,11 +819,11 @@ class StateStore(SQLBaseStore):
|
|||||||
def _background_index_state(self, progress, batch_size):
|
def _background_index_state(self, progress, batch_size):
|
||||||
def reindex_txn(conn):
|
def reindex_txn(conn):
|
||||||
conn.rollback()
|
conn.rollback()
|
||||||
|
if isinstance(self.database_engine, PostgresEngine):
|
||||||
# postgres insists on autocommit for the index
|
# postgres insists on autocommit for the index
|
||||||
conn.set_session(autocommit=True)
|
conn.set_session(autocommit=True)
|
||||||
try:
|
try:
|
||||||
txn = conn.cursor()
|
txn = conn.cursor()
|
||||||
if isinstance(self.database_engine, PostgresEngine):
|
|
||||||
txn.execute(
|
txn.execute(
|
||||||
"CREATE INDEX CONCURRENTLY state_groups_state_type_idx"
|
"CREATE INDEX CONCURRENTLY state_groups_state_type_idx"
|
||||||
" ON state_groups_state(state_group, type, state_key)"
|
" ON state_groups_state(state_group, type, state_key)"
|
||||||
@ -831,7 +831,10 @@ class StateStore(SQLBaseStore):
|
|||||||
txn.execute(
|
txn.execute(
|
||||||
"DROP INDEX IF EXISTS state_groups_state_id"
|
"DROP INDEX IF EXISTS state_groups_state_id"
|
||||||
)
|
)
|
||||||
|
finally:
|
||||||
|
conn.set_session(autocommit=False)
|
||||||
else:
|
else:
|
||||||
|
txn = conn.cursor()
|
||||||
txn.execute(
|
txn.execute(
|
||||||
"CREATE INDEX state_groups_state_type_idx"
|
"CREATE INDEX state_groups_state_type_idx"
|
||||||
" ON state_groups_state(state_group, type, state_key)"
|
" ON state_groups_state(state_group, type, state_key)"
|
||||||
@ -839,8 +842,6 @@ class StateStore(SQLBaseStore):
|
|||||||
txn.execute(
|
txn.execute(
|
||||||
"DROP INDEX IF EXISTS state_groups_state_id"
|
"DROP INDEX IF EXISTS state_groups_state_id"
|
||||||
)
|
)
|
||||||
finally:
|
|
||||||
conn.set_session(autocommit=False)
|
|
||||||
|
|
||||||
yield self.runWithConnection(reindex_txn)
|
yield self.runWithConnection(reindex_txn)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user