-
Notifications
You must be signed in to change notification settings - Fork 381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SET TRANSACTION ISOLATION behaviour when using ProxySQL #1043
Comments
This issue may belong to the underlying MySqlConnector library. Can you provide a full working example? |
What do you mean by a 'full working example'? private async ValueTask<MySqlTransaction> BeginDbTransactionAsync(IsolationLevel isolationLevel, IOBehavior ioBehavior, CancellationToken cancellationToken)
{
if (State != ConnectionState.Open)
throw new InvalidOperationException("Connection is not open.");
if (CurrentTransaction is object)
throw new InvalidOperationException("Transactions may not be nested.");
#if !NETSTANDARD1_3
if (m_enlistedTransaction is object)
throw new InvalidOperationException("Cannot begin a transaction when already enlisted in a transaction.");
#endif
string isolationLevelValue = isolationLevel;
switch (isolationLevel) {
IsolationLevel.ReadUncommitted => "read uncommitted",
IsolationLevel.ReadCommitted => "read committed",
IsolationLevel.RepeatableRead => "repeatable read",
IsolationLevel.Serializable => "serializable",
// "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",
_ => throw new NotSupportedException("IsolationLevel.{0} is not supported.".FormatInvariant(isolationLevel))
}
using (var cmd = new MySqlCommand("set transaction isolation level " + isolationLevelValue + "; start transaction;", this))
await cmd.ExecuteNonQueryAsync(ioBehavior, cancellationToken).ConfigureAwait(false);
var transaction = new MySqlTransaction(this, isolationLevel);
CurrentTransaction = transaction;
return transaction;
} |
@bgrainger Do you have any insight into this issue? |
Seems like a duplicate of mysql-net/MySqlConnector#774 (originally filed as mysql-net/MySqlConnector#772). (Ultimately it feels like a bug in ProxySQL; why can't it "parse multi-statements command with SET statement"?)
I don't know about ProxySQL, but this isn't how MySQL Server works. https://dev.mysql.com/doc/refman/8.0/en/set-transaction.html#set-transaction-scope
This is the desired behaviour, which is why MySqlConnector issues that statement.
It's "a" default level, but there's absolutely no guarantee that the server hasn't been configured with a different default level. So it should be issued every time so that ADO.NET semantics are followed, regardless of server defaults. |
Per sysown/proxysql#1728 (comment), it appears that ProxySQL may clear the Secondly, per sysown/proxysql#2305 (comment)
That would be harder to work around, since changing the isolation level for the connection (i.e., session) for an individual |
@bgrainger In case MySqlConnector does support non @NataliyaLev Currently, this should be possible using a library like Harmony or of course by compiling and shipping your own version of MySqlConnector. |
This is the workaround we found for now: { |
My interpretation of that was incorrect. The comment was indicating that that was a configuration change you could make to ProxySQL (it's not true out-of-the-box). Moreover, the comment seems wrong; according to https://github.com/sysown/proxysql/wiki/Global-variables#mysql-client_multi_statements it takes effect "when connecting to MySQL backends". Local testing indicates that ProxySQL still presents the |
@bgrainger How should we proceed here? Do you want to track this issue further on the MySqlConnector repo? |
Yes, I think this is a duplicate of mysql-net/MySqlConnector#774. |
Okay, I close this issue here then. |
Both these issues should be fixed in MySqlConnector 0.64.0. |
Steps to reproduce
Connect your application to MySQL via ProxySQL
Use transactions (context.Database.AutoTransactionsEnabled = true;)
You will see errors of this type:
MySQL_Session.cpp:5308:handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_COM_QUERY_qpo(): [WARNING] Unable to parse multi-statements command with SET statement: setting lock hostgroup . Command: set transaction isolation level repeatable read; start transaction;
The issue
The issue is that:
The desired behaviour:
Further technical details
MySQL version: 5.7
ProxySQL: 2.7
Operating system:
Pomelo.EntityFrameworkCore.MySql version: 2.1
Microsoft.AspNetCore.App version:
Other details about my project setup:
The text was updated successfully, but these errors were encountered: