Skip to content
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

Support query cancellation and deadlines using contexts #60

Closed
begelundmuller opened this issue Dec 19, 2022 · 1 comment · Fixed by #66
Closed

Support query cancellation and deadlines using contexts #60

begelundmuller opened this issue Dec 19, 2022 · 1 comment · Fixed by #66

Comments

@begelundmuller
Copy link
Contributor

Currently, the go-duckdb driver doesn't support cancelling queries when a context is cancelled. I just discovered it might be easy to add:

  • By implementing database/sql/driver.StmtExecContext instead of database/sql/driver.Stmt, we get access to the query context and can check for cancellation.
  • In statement.go, duckdb_execute_prepared is used to run a query. That will block for the duration of the entire query, which means we can't cancel a DuckDB query if the context gets cancelled. However, DuckDB provides an alternative that allows the caller to periodically regain control during query execution – it is duckdb_pending_prepared and related functions (docs).

It looks like the Julia driver moved to using this (PR) to allow garbage collection to run. We could use it to periodically check the context, and cancel a query if the context has been cancelled or exceeded its deadline.

What do you think of this idea? Would be happy to submit a PR for this

@marcboeker
Copy link
Owner

It would be great to have query cancellation added. I had already created a ticket (#43) for this some time ago.
A PR would be awesome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants