-
Notifications
You must be signed in to change notification settings - Fork 113
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
interrupt query on ctx cancel/timeout #143
Conversation
Consider the below code snippet where I only complete a single task for a pending result and than destroy pending to mock query cancellation i.e. call the same set of APIs that gets called in the driver during query cancellation.
I am seeing that |
@k-anshul Great find, thanks for the PR! |
@k-anshul Update: Has nothing to do with |
@k-anshul It's getting weirder:
Never finishes. But adding a
Can you reproduce the problem? |
@k-anshul It seems that the for loop, waiting for either a context cancel or I'm not sure yet if a |
Hey @marcboeker I added some logs to debug this further:
I see that when it takes very long for this query to get cancelled, duckDB runs very few tasks with last task taking much longer to run: Ideally duckDB need to return fast within tasks but not sure why it isn't happening here. Another approach we can take here is to wait on
This avoids the for loop problem but has an additional overhead of a separate goroutine which also calls a C API. |
Hi @k-anshul thanks for your suggestion with the goroutine. Without the for-loop we're missing the check for any pending tasks. Or have I missed something?
|
Hey @marcboeker So as I understand we can either call |
@k-anshul Ah okay, so we're switching from executing the query step by step in little tasks to executing it at once using Which means that getting rid of the incremental execution should also speed things up? |
Yes @marcboeker.
It avoids looping and continuously checking the status via C APIs but adds an an overhead of making a CGO call in a separate goroutine which can also spawn more thread(although as I understand |
@k-anshul Okay great, I've changed it in main and will make a release shortly. Thanks for debugging this! |
Should we also wait for duckDB team's inputs in case we are missing something here ? |
@k-anshul Yeah, probably we should do this 🙂 Hi @taniabogatsch could you please do us a favour and check this your colleagues if our approach on only using |
Hey @marcboeker We got the following reply from duckDB team :
Based on this input I think its better to call Thanks |
@k-anshul Thanks for the update! |
* interrupt query on ctx cancel/timeout * adding unit test * adding unit test - reduce timeout
It seems we need to interrupt the query as well when context is cancelled or timed out to properly stop the query.
Ref : https://discord.com/channels/909674491309850675/921073327009853451/1087993635997491241