✅ SQL Command Timeout does not work with async calls
Has anyone encountered the following issue? When using a sync call to the database, the command timeout parameter works, but when I'm using an async call it does not work?
See sample code below:
Removing the
CommandTimeout
, meaning using the default timeout of 30 seconds, works for sync calls but not with async calls.
I tried adding a connection timeout and it also does not work. I tried using Dapper, and it also does not work. Am I missing something or what?5 Replies
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
Cheesus crust.
The problem is with MySql.Data, I tried using Pomelo as some suggested in other forums. But going back to your reply, yes, I do have cancellationToken and a command timeout. The problem was that if my client didn't configure a proper timeout, the query will run indefinitely because the cancellation does not work. So the command timeout is there as a final catch for this kind of scenario. And do note that this query is expected to run for more than few seconds due to the nature of the schema and that the query is there for the sake of example. I'll open an issue with MySql.Data. And use Pomelo nuget instead.
CommandTimeout
and CancellationToken
s are indeed working.The problem is with MySql.Data, I tried using Pomelo as some suggested in other forums. But going back to your reply, yes, I do have cancellationToken and a command timeout. The problem was that if my client didn't configure a proper timeout, the query will run indefinitely because the cancellation does not work. So the command timeout is there as a final catch for this kind of scenario. And do note that this query is expected to run for more than few seconds due to the nature of the schema and that the query is there for the sake of example. I'll open an issue with MySql.Data. And use Pomelo nuget instead.
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
Yes, thanks for this, I considered your proposal and it looks better now. I also did combine CancellationTokens from the controller and the database request.
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View