mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 13:46:02 -04:00
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.
This commit is contained in:
parent
52a50e8686
commit
ae5b2a72c0
7 changed files with 112 additions and 8 deletions
|
@ -17,6 +17,7 @@ import threading
|
|||
import typing
|
||||
|
||||
from synapse.storage.engines import BaseDatabaseEngine
|
||||
from synapse.storage.types import Connection
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
import sqlite3 # noqa: F401
|
||||
|
@ -86,6 +87,7 @@ class Sqlite3Engine(BaseDatabaseEngine["sqlite3.Connection"]):
|
|||
|
||||
db_conn.create_function("rank", 1, _rank)
|
||||
db_conn.execute("PRAGMA foreign_keys = ON;")
|
||||
db_conn.commit()
|
||||
|
||||
def is_deadlock(self, error):
|
||||
return False
|
||||
|
@ -105,6 +107,14 @@ class Sqlite3Engine(BaseDatabaseEngine["sqlite3.Connection"]):
|
|||
"""
|
||||
return "%i.%i.%i" % self.module.sqlite_version_info
|
||||
|
||||
def in_transaction(self, conn: Connection) -> bool:
|
||||
return conn.in_transaction # type: ignore
|
||||
|
||||
def attempt_to_set_autocommit(self, conn: Connection, autocommit: bool):
|
||||
# Twisted doesn't let us set attributes on the connections, so we can't
|
||||
# set the connection to autocommit mode.
|
||||
pass
|
||||
|
||||
|
||||
# Following functions taken from: https://github.com/coleifer/peewee
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue