Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Backport fixes to sqlite upgrade from develop #6578

Merged
merged 1 commit into from
Dec 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/6578.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug introduced in Synapse 1.7.0 which caused an error on startup when upgrading from versions before 1.3.0.
10 changes: 9 additions & 1 deletion synapse/storage/engines/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -59,7 +62,12 @@ def convert_param_style(self, sql):
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):
Expand Down