mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 09:56:05 -04:00
Add logging on startup/shutdown (#8448)
This is so we can tell what is going on when things are taking a while to start up. The main change here is to ensure that transactions that are created during startup get correctly logged like normal transactions.
This commit is contained in:
parent
ec10bdd32b
commit
e3debf9682
25 changed files with 152 additions and 113 deletions
|
@ -17,6 +17,7 @@ import logging
|
|||
import threading
|
||||
from typing import Callable, List, Optional
|
||||
|
||||
from synapse.storage.database import LoggingDatabaseConnection
|
||||
from synapse.storage.engines import (
|
||||
BaseDatabaseEngine,
|
||||
IncorrectDatabaseSetup,
|
||||
|
@ -53,7 +54,11 @@ class SequenceGenerator(metaclass=abc.ABCMeta):
|
|||
|
||||
@abc.abstractmethod
|
||||
def check_consistency(
|
||||
self, db_conn: Connection, table: str, id_column: str, positive: bool = True
|
||||
self,
|
||||
db_conn: LoggingDatabaseConnection,
|
||||
table: str,
|
||||
id_column: str,
|
||||
positive: bool = True,
|
||||
):
|
||||
"""Should be called during start up to test that the current value of
|
||||
the sequence is greater than or equal to the maximum ID in the table.
|
||||
|
@ -82,9 +87,13 @@ class PostgresSequenceGenerator(SequenceGenerator):
|
|||
return [i for (i,) in txn]
|
||||
|
||||
def check_consistency(
|
||||
self, db_conn: Connection, table: str, id_column: str, positive: bool = True
|
||||
self,
|
||||
db_conn: LoggingDatabaseConnection,
|
||||
table: str,
|
||||
id_column: str,
|
||||
positive: bool = True,
|
||||
):
|
||||
txn = db_conn.cursor()
|
||||
txn = db_conn.cursor(txn_name="sequence.check_consistency")
|
||||
|
||||
# First we get the current max ID from the table.
|
||||
table_sql = "SELECT GREATEST(%(agg)s(%(id)s), 0) FROM %(table)s" % {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue