-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
InvalidOperationException when using MySQLExecutor and Pipelined query #1469
Comments
It sounds like your chosen provider doesn't support pipelining,or it isn't enabled. Most simply do not, and even those that do: sometimes (for example SqlClient) require it to be opt-in enabled on the connection string. So: if it isn't enabled: don't specify the pipelined flag. That's why we make it opt-in. |
Just to clarify - |
No, I absolutely cannot "confirm" anything about either of those two providers. They're not my providers. But anecdotally, it would seem a reasonable conclusion based on the available data. It is a niche feature that very few providers support. It wouldn't surprise me to find another that doesn't. |
I'm not familiar with Dapper's pipelining feature (it's not mentioned at https://github.com/StackExchange/Dapper/blob/master/Readme.md). This may be a MySqlConnector bug (over-zealous enforcement of preconditions), or it may not actually be supported. If it does work with MySql.Data, it could be because none of its async methods are actually asynchronous (https://bugs.mysql.com/bug.php?id=70111) so async methods might just be executing in a synchronous loop. I've opened a case to investigate: mysql-net/MySqlConnector#823 This issue can be closed, because the problem is highly unlikely to be on Dapper's end. |
(Commenting here rather than on the MySqlConnector issue so Marc can set me straight if I'm misunderstanding.) I've looked over the pipelining code in SqlMapper.Async.cs line 547ff: https://github.com/StackExchange/Dapper/blob/d403fa5b5481291ca84aaf11ac4d61a1034d3b72/Dapper/SqlMapper.Async.cs#L547 It appears to create a queue of up to 100 (Also, my guess above was right, because MySql.Data will always return an already-completed The simple answer is: this isn't supported. The real answer is: it's complicated. Some MySQL servers (e.g., MySQL, MariaDB) do support pipelining. Others (e.g., Aurora) will fail hard if this is attempted. However, this isn't exposed through the MySqlConnector ADO.NET API at all. For "safety" reasons (most attempts to do this are incorrect usage of the API that will generate incorrect results), and to keep the code (much) simpler (from not having to track multiple in-flight operations with thread-safe code and align the results to the If you want a more efficient way of executing multiple commands, you could bypass Dapper and use |
I am using Piplined Dapper queries with
I am not so sure about it (that the task is already completed when using |
I can guarantee you it's not pipelining them. The only occurrence of (The method you're calling is actually in the base The commands are being executed synchronously one after the other.
I can't see an obvious reason for that in the Dapper code. (Unless reusing a
In MySqlConnector, a |
Closing this issue as it's explained well here - pipelined queries are actually not supported by MySQL. |
The above Exception is thrown when executing the
ExecuteAsync
method,CommandDefinition
havingflags: CommandFlags.Pipelined
and more than 2 rows require inserting. E.g.The exception:
Exception is happening for
MySqlConnector
version 0.66.0 (not tested with previous versions) andDapper
versions 1.50.5-2.0.35.Application is run on .NET Core 2.1.
When switching to MySQL.Data library the above query works fine.
The text was updated successfully, but these errors were encountered: