SQLProvider
SQLProvider copied to clipboard
Any support for cancellation tokens?
In the api , I am not seeing any support for cancellation. Is it possible to cancel long running queries ?
There is timeout parameter for .GetDataContext
method.
If you use Async methods, you could do your own:
module Async =
/// Async.Start with timeout in seconds
let StartWithTimeout (timeoutSecs:int) (computation:Async<unit>) =
let c = new System.Threading.CancellationTokenSource(timeoutSecs*1000)
Async.Start(computation, cancellationToken = c.Token)
...however the query will run in the end in the background. I don't know if there is database-specific commands to cancel execution. SQLProvider can commit to transactions, so cancelling a query should also roll-back the transaction.
There is a DBCommand.Cancel. https://docs.microsoft.com/en-us/dotnet/api/system.data.common.dbcommand.cancel?view=net-5.0 So perhaps this could be utilized.
My concern is let's say there is a DB query running potentially long, and we want to give the opportunity to cancel to the client so that the query won't be exhausting DB resources or to make sure the the query/trx is cancelled