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

Cancel the DB side query when doobie execution is cancelled #1922

Open
jatcwang opened this issue Sep 13, 2023 · 4 comments
Open

Cancel the DB side query when doobie execution is cancelled #1922

jatcwang opened this issue Sep 13, 2023 · 4 comments

Comments

@jatcwang
Copy link
Collaborator

jatcwang commented Sep 13, 2023

If we run a long running query but then cancel it (e.g. application-side timeout or IO.race), we might want to cancel the DB side query by calling PreparedStatement#cancel(). (Simply calling close() which we currently do does not seem to cancel the query on the DB-side)

e.g. https://discord.com/channels/632277896739946517/632727524434247691/1151507294664786021

Will need some more thought on whether this is universally desirable, and if not we'll need to make this configurable somehow (e.g. opt-in or opt-out)

@armanbilge
Copy link
Contributor

if not we'll need to make this configurable somehow (e.g. opt-in or opt-out)

Repeating my comment from Discord: a user can always opt-out of cancelation by adding .uncancelable.

@AlekseyKovalevsky
Copy link

Hello! Can I as a user customise transactor somehow from the outside to get the behaviour mentioned? Just not to wait for this feature to be implemented.

@jatcwang
Copy link
Collaborator Author

jatcwang commented Oct 6, 2023

@AlekseyKovalevsky In plain Java/JDBC, what needs to be called is PreparedStatement#cancel, but this has to be done from another thread (since JDBC operations are blocking). Therefore in order to do the same in Doobie I think we'll need to fork a fiber to cancel the preparedstatement when a cancellation is signaled from the caller of .transact.

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

No branches or pull requests

3 participants