summary refs log tree commit diff
path: root/synapse/storage/engines/_base.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2020-10-07 15:15:57 +0100
committerErik Johnston <erik@matrix.org>2020-10-07 17:08:58 +0100
commitfa8934b175467d589dd34fae18639cac0d738fc9 (patch)
treeb47f6e6628a61a5b6689ed576c98ec59b3542a8d /synapse/storage/engines/_base.py
parentAdd Ubuntu 20.10 (Groovy Gorilla) to build scripts. (#8475) (diff)
downloadsynapse-fa8934b175467d589dd34fae18639cac0d738fc9.tar.xz
Reduce serialization errors in MultiWriterIdGen (#8456)
We call `_update_stream_positions_table_txn` a lot, which is an UPSERT
that can conflict in `REPEATABLE READ` isolation level. Instead of doing
a transaction consisting of a single query we may as well run it outside
of a transaction.
Diffstat (limited to 'synapse/storage/engines/_base.py')
-rw-r--r--synapse/storage/engines/_base.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/synapse/storage/engines/_base.py b/synapse/storage/engines/_base.py

index 908cbc79e3..d6d632dc10 100644 --- a/synapse/storage/engines/_base.py +++ b/synapse/storage/engines/_base.py
@@ -97,3 +97,20 @@ class BaseDatabaseEngine(Generic[ConnectionType], metaclass=abc.ABCMeta): """Gets a string giving the server version. For example: '3.22.0' """ ... + + @abc.abstractmethod + def in_transaction(self, conn: Connection) -> bool: + """Whether the connection is currently in a transaction. + """ + ... + + @abc.abstractmethod + def attempt_to_set_autocommit(self, conn: Connection, autocommit: bool): + """Attempt to set the connections autocommit mode. + + When True queries are run outside of transactions. + + Note: This has no effect on SQLite3, so callers still need to + commit/rollback the connections. + """ + ...