-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Reduce serialization errors in MultiWriterIdGen #8456
Changes from 5 commits
d8c2c96
8644ce0
0e5c73b
201d2da
9be577c
b16b7ef
8385e95
9741ca7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Reduce number of serialization errors of `MultiWriterIdGenerator._update_table`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
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 @@ def on_new_connection(self, db_conn): | |
|
||
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 @@ def server_version(self): | |
""" | ||
return "%i.%i.%i" % self.module.sqlite_version_info | ||
|
||
def in_transaction(self, conn: Connection) -> bool: | ||
return conn.in_transaction # type: ignore | ||
|
||
def 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. | ||
Comment on lines
+114
to
+115
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what's Twisted to do with it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The connections we get are Twisted connections that wrap the underlying native connections, the wrapper implements There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh, right. I suppose you could delve into There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, we could go and pull out |
||
pass | ||
|
||
|
||
# Following functions taken from: https://github.com/coleifer/peewee | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the problem with disabling this is that it's the thing that deals with postgres connections dropping (which can happen for annoying TCP reasons). I'm not sure it's safe to do: why is it required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unlike functions that are run in transactions its not necessarily true its safe to just re-run transaction functions, since they might have done half the work already. I guess we can mandate that such functions should be safe to re-run? (All the usages are for example)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've done that.