Bug #110790 ExecuteReaderAsync hangs instead of cancelling query after CommandTimeout
| Submitted: | 24 Apr 2023 18:37 | Modified: | 7 Jun 2023 15:05 |
|---|---|---|---|
| Reporter: | Bradley Grainger (OCA) | Email Updates: | |
| Status: | In progress | Impact on me: | |
| Category: | Connector / NET | Severity: | S2 (Serious) |
| Version: | 8.0.33 | OS: | Windows (10) |
| Assigned to: | CPU Architecture: | Any |
[7 Jun 2023 15:05]
MySQL Verification Team
Hello Bradley Grainger, Thank you for the bug report. Verified as described. Regards, Ashwini Patil
[28 May 1:13]
MySQL Admin
Posted by developer: Bug status updated to 'Patch pending'
[23 Jul 20:48]
MySQL Admin
Posted by developer: Bug status updated to 'In progress'
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.054 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: When CommandTimeout is set, MySqlCommand.ExecuteReaderAsync hangs forever instead of (a) cancelling the query after the CommandTimeout, or (b) returning when the command actually does finish. The problem only occurs when using ExecuteReaderAsync, not ExecuteReader. This is a regression from 8.0.32.1. The expected behavior from the test program is to print the following output. This happens for 8.0.32.1 and for ExecuteReader (in 8.0.33), but not for ExecuteReaderAsync in 8.0.33. Even if the command weren't cancelled, the program should finish running after about five seconds (when SELECT SLEEP(5) finishes); however, it just hangs. Exception 'Fatal error encountered during command execution.' after 00:00:02.0165024 ExecuteReaderAsync finished after 00:00:02.0190520 How to repeat: Run the following C# code: using var connection = new MySqlConnection("..."); await connection.OpenAsync(); using var command = new MySqlCommand("SELECT SLEEP(5);", connection) { CommandTimeout = 2 }; var stopwatch = Stopwatch.StartNew(); try { // Works; prints message: Exception 'Fatal error encountered during command execution.' after 00:00:02.0166766 // using var reader = command.ExecuteReader(); // hangs forever using var reader = await command.ExecuteReaderAsync(); } catch (Exception ex) { Console.WriteLine($"Exception '{ex.Message}' after {stopwatch.Elapsed}"); } Console.WriteLine($"ExecuteReaderAsync finished after {stopwatch.Elapsed}");