summary refs log tree commit diff
path: root/synapse/storage/database.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2021-01-14 17:19:35 +0000
committerGitHub <noreply@github.com>2021-01-14 17:19:35 +0000
commit659c415ed4e081d7d26f272f1f1cccb99d0fb016 (patch)
treeb8f4895483383ee2fe24c24d6658c29959893f9c /synapse/storage/database.py
parentFix get destinations to catch up query. (#9114) (diff)
downloadsynapse-659c415ed4e081d7d26f272f1f1cccb99d0fb016.tar.xz
Fix chain cover background update to work with split out event persisters (#9115)
Diffstat (limited to 'synapse/storage/database.py')
-rw-r--r--synapse/storage/database.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/synapse/storage/database.py b/synapse/storage/database.py

index 6cfadc2b4e..a19d65ad23 100644 --- a/synapse/storage/database.py +++ b/synapse/storage/database.py
@@ -49,6 +49,7 @@ from synapse.metrics.background_process_metrics import run_as_background_process from synapse.storage.background_updates import BackgroundUpdater from synapse.storage.engines import BaseDatabaseEngine, PostgresEngine, Sqlite3Engine from synapse.storage.types import Connection, Cursor +from synapse.storage.util.sequence import build_sequence_generator from synapse.types import Collection # python 3 does not have a maximum int value @@ -412,6 +413,16 @@ class DatabasePool: self._check_safe_to_upsert, ) + # We define this sequence here so that it can be referenced from both + # the DataStore and PersistEventStore. + def get_chain_id_txn(txn): + txn.execute("SELECT COALESCE(max(chain_id), 0) FROM event_auth_chains") + return txn.fetchone()[0] + + self.event_chain_id_gen = build_sequence_generator( + engine, get_chain_id_txn, "event_auth_chain_id" + ) + def is_running(self) -> bool: """Is the database pool currently running """