mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-04 17:55:06 -04:00
Db txn set isolation level (#11799)
Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
This commit is contained in:
parent
fc8598bc87
commit
b59d285f7c
5 changed files with 61 additions and 5 deletions
|
@ -12,11 +12,18 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
import abc
|
||||
from typing import Generic, TypeVar
|
||||
from enum import IntEnum
|
||||
from typing import Generic, Optional, TypeVar
|
||||
|
||||
from synapse.storage.types import Connection
|
||||
|
||||
|
||||
class IsolationLevel(IntEnum):
|
||||
READ_COMMITTED: int = 1
|
||||
REPEATABLE_READ: int = 2
|
||||
SERIALIZABLE: int = 3
|
||||
|
||||
|
||||
class IncorrectDatabaseSetup(RuntimeError):
|
||||
pass
|
||||
|
||||
|
@ -109,3 +116,13 @@ class BaseDatabaseEngine(Generic[ConnectionType], metaclass=abc.ABCMeta):
|
|||
commit/rollback the connections.
|
||||
"""
|
||||
...
|
||||
|
||||
@abc.abstractmethod
|
||||
def attempt_to_set_isolation_level(
|
||||
self, conn: Connection, isolation_level: Optional[int]
|
||||
):
|
||||
"""Attempt to set the connections isolation level.
|
||||
|
||||
Note: This has no effect on SQLite3, as transactions are SERIALIZABLE by default.
|
||||
"""
|
||||
...
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue