summary refs log tree commit diff
path: root/synapse/storage/engines/_base.py
diff options
context:
space:
mode:
authorPatrick Cloke <patrickc@matrix.org>2023-11-15 13:38:57 -0500
committerPatrick Cloke <patrickc@matrix.org>2023-11-15 15:11:51 -0500
commit9622bda16329a1f10daf3f57a75f5444483e0447 (patch)
treeda95a97808b41e16283e9d13f374b5b933798674 /synapse/storage/engines/_base.py
parentAdd an Admin API to temporarily grant the ability to update an existing cross... (diff)
downloadsynapse-github/clokep/statement-timeout.tar.xz
Abstract logic for setting the statement timeout. github/clokep/statement-timeout clokep/statement-timeout
Diffstat (limited to 'synapse/storage/engines/_base.py')
-rw-r--r--synapse/storage/engines/_base.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/synapse/storage/engines/_base.py b/synapse/storage/engines/_base.py

index b1a2418cbd..888b4a5660 100644 --- a/synapse/storage/engines/_base.py +++ b/synapse/storage/engines/_base.py
@@ -36,6 +36,9 @@ CursorType = TypeVar("CursorType", bound=Cursor) class BaseDatabaseEngine(Generic[ConnectionType, CursorType], metaclass=abc.ABCMeta): + # The default statement timeout to use for transactions. + statement_timeout: Optional[int] = None + def __init__(self, module: DBAPI2Module, config: Mapping[str, Any]): self.module = module @@ -132,6 +135,16 @@ class BaseDatabaseEngine(Generic[ConnectionType, CursorType], metaclass=abc.ABCM """ ... + @abc.abstractmethod + def attempt_to_set_statement_timeout( + self, cursor: CursorType, statement_timeout: int, for_transaction: bool + ) -> None: + """Attempt to set the cursor's statement timeout. + + Note this has no effect on SQLite3. + """ + ... + @staticmethod @abc.abstractmethod def executescript(cursor: CursorType, script: str) -> None: