Replace device_27_unique_idx bg update with a fg one (#7562)

The bg update never managed to complete, because it kept being interrupted by
transactions which want to take a lock.

Just doing it in the foreground isn't that bad, and is a good deal simpler.
This commit is contained in:
Richard van der Hoff 2020-05-26 11:43:17 +01:00 committed by GitHub
parent 04729b86f8
commit edd9a7214c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 104 additions and 65 deletions

View file

@ -19,10 +19,12 @@ import logging
import os
import re
from collections import Counter
from typing import TextIO
import attr
from synapse.storage.engines.postgres import PostgresEngine
from synapse.storage.types import Cursor
logger = logging.getLogger(__name__)
@ -479,8 +481,7 @@ def _apply_module_schema_files(cur, database_engine, modname, names_and_streams)
)
logger.info("applying schema %s for %s", name, modname)
for statement in get_statements(stream):
cur.execute(statement)
execute_statements_from_stream(cur, stream)
# Mark as done.
cur.execute(
@ -538,8 +539,12 @@ def get_statements(f):
def executescript(txn, schema_path):
with open(schema_path, "r") as f:
for statement in get_statements(f):
txn.execute(statement)
execute_statements_from_stream(txn, f)
def execute_statements_from_stream(cur: Cursor, f: TextIO):
for statement in get_statements(f):
cur.execute(statement)
def _get_or_create_schema_state(txn, database_engine):