Skip to content
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

ServerSession.FinishQuerying throws InvalidOperationException due to possible race #1341

Closed
bgrainger opened this issue Jul 3, 2023 · 1 comment

Comments

@bgrainger
Copy link
Member

Software versions
MySqlConnector version: 2.2.2
Server type (MySQL, MariaDB, Aurora, etc.) and version: AzureDatabase for MySQL 5.7
.NET version: .NET Framework 4.7.2
(Optional) ORM NuGet packages and versions: Dapper 1.60.6

Describe the bug

ServerSession.FinishQuerying throws an InvalidOperationException.

Exception

System.InvalidOperationException: Expected state to be Failed but was CancelingQuery.
   at void MySqlConnector.Core.ServerSession.VerifyState(State state) in /_/src/MySqlConnector/Core/ServerSession.cs:line 1797
   at void MySqlConnector.Core.ServerSession.FinishQuerying() in /_/src/MySqlConnector/Core/ServerSession.cs:line 328
   at void MySqlConnector.MySqlConnection.FinishQuerying(bool hasWarnings) in /_/src/MySqlConnector/MySqlConnection.cs:line 885
   at async Task MySqlConnector.MySqlDataReader.DisposeAsync(IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlDataReader.cs:line 631
   at void MySqlConnector.MySqlDataReader.Dispose(bool disposing) in /_/src/MySqlConnector/MySqlDataReader.cs:line 439
   at async Task<int> MySqlConnector.MySqlCommand.ExecuteNonQueryAsync(IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlCommand.cs:line 303
   at async Task<int> Dapper.SqlMapper.ExecuteImplAsync(IDbConnection cnn, CommandDefinition command, object param) in C:/projects/dapper/Dapper/SqlMapper.Async.cs:line 678

Expected behavior

No exception. Query should be cancelled successfully (if cancellation happens).

Additional context

There may be a race condition between here and here.

@bgrainger
Copy link
Member Author

Fixed in 2.4.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant