diff options
author | Erik Johnston <erik@matrix.org> | 2020-10-07 15:15:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-07 15:15:57 +0100 |
commit | ae5b2a72c09d67311c9830f5a6fae1decce03e1f (patch) | |
tree | 47298b27adc6f433eea630e4015633c042131787 /synapse/storage/engines/_base.py | |
parent | Use vector clocks for room stream tokens. (#8439) (diff) | |
download | synapse-ae5b2a72c09d67311c9830f5a6fae1decce03e1f.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.py | 17 |
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. + """ + ... |