Skip to content

Transaction isolation level should not default to REPEATABLE READ regardless of server configuration if left unspecified #1442

Open
@bdach

Description

@bdach

Software versions
MySqlConnector version: 2.1.6, but still relevant on latest master as far as I can tell
Server type (MySQL, MariaDB, Aurora, etc.) and version: Not relevant
.NET version: Not relevant

Describe the bug
If a transaction is started without specifying an isolation level, it will silently default to IsolationLevel.Unspecified, which is really just REPEATABLE READ:

// "In terms of the SQL:1992 transaction isolation levels, the default InnoDB level is REPEATABLE READ." - http://dev.mysql.com/doc/refman/5.7/en/innodb-transaction-model.html
IsolationLevel.Unspecified => "repeatable read",

The comment is correct in stating that REPEATABLE READ is the default innodb transaction isolation level, however, this is confusing in cases where the global transaction isolation level on the mysql instance that queries are directed to is deliberately changed from the configuration default.

Related: #772

Exception
Not applicable

Code sample
See usage. On a mysql transaction with READ COMMITTED default transaction isolation level this would instead force REPEATABLE READ and as such caused a long investigation into ensuing deadlocks, that was "fixed" by ppy/osu-queue-score-statistics@5c23e0f.

Expected behavior
MySqlConnector does not attempt to explicitly set any transaction isolation level when starting a transaction with IsolationLevel.Unspecified.

Additional context
Not applicable

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions