Skip to content

Ensure Query Cancellation on Context Deadline Expiry #140

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

Merged

Conversation

Flgado
Copy link
Member

@Flgado Flgado commented Apr 1, 2025

Problem description

  • When the driver is used with a context deadline, and the deadline is reached before processing all data, the driver does not cancel the underlying Trino query. This happens because the expiration of the context deadline isn't properly handled, and the driver does not trigger the necessary steps to cancel the query.

Solution

This pull request addresses the issue by ensuring that the Close method is called when the context deadline is reached. This method will initiate a delete request, notifying Trino to cancel the corresponding underlying query. By adding this behavior, the query will be properly canceled when the context deadline expires, preventing unnecessary resource usage and improving the overall reliability of the system.

Copy link

cla-bot bot commented Apr 1, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

Copy link
Member

@nineinchnick nineinchnick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some nitpicks, looks good otherwise. Thanks for working on this!

Copy link

cla-bot bot commented Apr 2, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@nineinchnick
Copy link
Member

@cla-bot check

@cla-bot cla-bot bot added the cla-signed label Apr 14, 2025
Copy link

cla-bot bot commented Apr 14, 2025

The cla-bot has been summoned, and re-checked this pull request!

@nineinchnick nineinchnick added enhancement New feature or request bug Something isn't working and removed enhancement New feature or request labels Apr 14, 2025
@nineinchnick
Copy link
Member

@Flgado can you squash both commits? This is ready to be merged

@Flgado Flgado force-pushed the cancel_underling_trino_query_deadline branch from 28cdd7e to 2f5be5f Compare April 14, 2025 18:22
@Flgado
Copy link
Member Author

Flgado commented Apr 14, 2025

@nineinchnick done

@nineinchnick nineinchnick merged commit 3c2f549 into trinodb:master Apr 15, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cla-signed
Development

Successfully merging this pull request may close these issues.

2 participants