-
Notifications
You must be signed in to change notification settings - Fork 336
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
CancellationToken vs the CancellationTimeout in v1.2.1 #942
Comments
The details are currently discussed here: #455 (comment). In summary:
This is improved in 1.1.0 (for exactly these reasons).
Yes.
It should be redundant if you're setting it for the same amount of time.
No, opposite. |
Thanks! Everything is more clear now. We didn't set the CancellationTimeout in our connection string, basically this will be set as 2 seconds right? since the default value for CancellationTimeout is 2 seconds i think? lastly, will it be safe if we will retain our approach on using the CancellationToken in our ExecuteReaderAsync with a value that is lowered the Default CommandTimout by 2 secs? (e.g. example the Default CommandTimout is 8 secs, and the CancellationToken is 6 secs). |
That's correct. (You may want to increase it if there's significant latency between your database client and database server, but the default should be fine.)
There's nothing "unsafe" about that. This will result in an Personally, I reserve the |
Thanks @bgrainger! We will remove the CancellationToken timeout and will totally rely on the Default CommandTimout already since this will cancel the running query if timeout reaches. |
I've added some documentation for this: https://mysqlconnector.net/overview/command-cancellation/ |
Thank you! @bgrainger |
Hi,
I would like to clarify on how the Default Command Timeout (connection string), CancellationTimeout (connection string) and the CancellationToken (c# code async) works in the latest library version 1.2.1.
Before, we are using CancellationToken to cancel and kill the query if it exceeds the running time since the Default Command Timeout in the connection string doesn't cancel and kill the query, it just closes the socket and it can cause a lot of negative domino effects on the Db server.
using (CancellationTokenSource cts = new CancellationTokenSource(DbDefaultCommandTimeoutClientMilliseconds))
{
result = await myCommand.ExecuteReaderAsync(cts.Token);
Now we have tried updating to the latest version, and i am now seeing a new config (CancellationTimeout ) and changes on how Default Command Timeout works already, i am still confused on how these timeouts works. Could you ellaborate further?
With the new library, can I safely assume that the Default Command Timeout + CancellationTimeout will trigger the canceling and killing the query if it reaches the timeout? What will happen if i would still use the CancellationToken approach? And also Is the CancellationTimeout who is the one killing the query (based on your documentation here: https://mysqlconnector.net/connection-options/) after X seconds? So basically the Default Command Timeout works like before if there is no CancellationTimeout (-1) right? It is important to set the CancellationTimeout (above 0) so that it will auto kill and cancel the running query?
The text was updated successfully, but these errors were encountered: