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

Fix unnecessary cancel requests #136

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Flgado
Copy link

@Flgado Flgado commented Mar 3, 2025

Overview

This PR fixes unnecessary delete requests when the query is already finished.

Explanation

This change addresses Issue #102

  • When using QueryRow followed by a Scan, the Trino driver first calls the Next method and then the Close method. The Close method triggers a delete request to cancel the query, even when the query has already completed.
  • My initial approach was to use nextUri in the Close method instead of directly calling /v1/query/queryId, as suggested in the documentation and implemented by other drivers. However, to make this work, I needed to always update rows.nextUri inside the fetch method, as it was previously retaining only the first URI set here. Despite these changes, the issue persisted.
  • To resolve this, I modified the Next method so that when all rows have been read, it fetches the next set of rows. This works because our fetch method, along with the running Goroutines, follows nextUri until data is retrieved.
    • For QueryRow, this ensures that when the query reaches the finished state with no more data, nextUri is cleared, preventing an unnecessary request on Close().
    • For QueryContext, this is also fine because it fetches the next batch of data, ensuring that additional data (if available) is retrieved correctly.

Copy link

cla-bot bot commented Mar 3, 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

cla-bot bot commented Mar 3, 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

Copy link

cla-bot bot commented Mar 13, 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

cla-bot bot commented Mar 13, 2025

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

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

Successfully merging this pull request may close these issues.

2 participants