-
Notifications
You must be signed in to change notification settings - Fork 335
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
If a query result has multiple rows, timeouts aren't always triggered properly #1501
Comments
I haven't dug into this deeply, but any repro with Do you have a repro (or a production scenario) that doesn't use |
It does the same if you replace SLEEP with BENCHMARK(9999999, md5('hmmmm')), but maybe this also qualifies as an interruptable query? |
I don't think the |
If you don't While this is happening, the query is cancelled because of the So, since it was first implemented, cancellation in MySqlConnector swallows this exception in Dispose: 3e4d8f5#diff-a8b0743221709c433a3aec2081e850eb5f55a97f7705eb3312ff2c44305b38c9. If you have logging enabled, you will see this exception in your logs (at a "Warning" level). To observe the exception, you need to read all rows of the MySqlDataReader. The standard pattern for doing this is (sync example given): using (var reader = command.ExecuteReader())
{
do
{
while (reader.Read())
{
// ...
}
}
while (reader.NextResult());
} Any decent ORM (like EFCore or Dapper) should do this for you automatically. If you have to use plain ADO.NET, you should always use a |
Software versions
MySqlConnector version: 2.3.7
Server type (MySQL, MariaDB, Aurora, etc.) and version: Mysql 8.0
.NET version:
6.0
Describe the bug
I can't tell if this is a bug or not but it feels like one. If you execute a query that has multiple rows where one row seems to be "ready" already, the .CommandTimeout property doesn't work as you would expect. CancellationToken query cancellation displays the same behaviour.
The query below is attempting to select 3 rows, with the values {1,0,2}. A timeout of 10 seconds is specified, but if you don't Read() the row that would've triggered the timeout on the command there is no exception being generated and it appears as if the query worked as expected.
The server thread is still cancelled after 1 second as expected, but there is no timeout exception triggered.
Code sample
Inserts are even weirder:
The second example triggers no exception, and if you check the database afterwards it contains two rows with values 1,2.
Expected behavior
We would expect an exception to be triggered after 1 seconds no matter what the server thread was doing, no?
The text was updated successfully, but these errors were encountered: