Skip to content
Snippets Groups Projects
Unverified Commit 4caab0e9 authored by Richard van der Hoff's avatar Richard van der Hoff Committed by GitHub
Browse files

Backport fixes to sqlite upgrade from develop (#6578)

Only run prepare_database on connection for in-memory databases.

Fixes #6569.
parent 03d3792f
No related branches found
No related tags found
No related merge requests found
Fix a bug introduced in Synapse 1.7.0 which caused an error on startup when upgrading from versions before 1.3.0.
......@@ -25,6 +25,9 @@ class Sqlite3Engine(object):
def __init__(self, database_module, database_config):
self.module = database_module
database = database_config.get("args", {}).get("database")
self._is_in_memory = database in (None, ":memory:",)
# The current max state_group, or None if we haven't looked
# in the DB yet.
self._current_state_group_id = None
......@@ -59,7 +62,12 @@ class Sqlite3Engine(object):
return sql
def on_new_connection(self, db_conn):
prepare_database(db_conn, self, config=None)
if self._is_in_memory:
# In memory databases need to be rebuilt each time. Ideally we'd
# reuse the same connection as we do when starting up, but that
# would involve using adbapi before we have started the reactor.
prepare_database(db_conn, self, config=None)
db_conn.create_function("rank", 1, _rank)
def is_deadlock(self, error):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment