Repository navigation
Conversation
…causing duplicate query submissions and a crash- #1 (#167) ### Rationale for this change SQLCancel was an unimplemented placeholder that unconditionally threw "SQLCancel is not implemented" (IM001), even though the underlying cancellation plumbing already existed. When Excel/Power BI try to cancel a long-running fetch and SQLCancel fails, they abandon the statement and resubmit the same query. ### What changes are included in this PR? * entry_points.cc: SQLCancel now calls ODBCStatement::Cancel() and returns SQL_SUCCESS instead of throwing. * FlightStreamChunkBuffer: retains each DoGet stream's FlightStreamReader and adds Cancel(), which calls FlightStreamReader::Cancel() (gRPC TryCancel) before closing the queue, so Close() doesn't hang joining a producer thread blocked in Next(). * FlightSqlResultSet::Cancel() now goes through the new FlightStreamChunkBuffer::Cancel() path. * FlightSqlStatement guards current_result_set_ with a mutex, since SQLCancel must be safe to call from a different thread than the one blocked in SQLExecute/SQLFetch. This covers cancellation while fetching rows (the reported scenario). The initial query-execution RPC itself still can't be interrupted mid-flight -- Arrow's gRPC Flight transport doesn't expose a cancel hook for that unary call; that would need a separate transport-layer change. ### Are these changes tested? Yes. TestSQLCancelOnIdleStatement and TestSQLCancelDuringFetch, which failed (and crashed) before the fix, now pass -- tested against the mock server and manual verification through Excel. ### Are there any user-facing changes? No public API changes. **This PR contains a "Critical Fix".** It fixes a crash (libc++abi terminating) caused by a stuck fetch thread with no way to be cancelled. **PR code and description written by:** - [x] Human - [x] AI **Reviewed before submission by:** - [x] Human - [ ] AI - [ ] Not reviewed * GitHub Issue: apache#55790
Collaborator
|
Comment for PR description:
|
alinaliBQ
approved these changes
Dec 3, 2026
alinaliBQ
left a comment
Collaborator
There was a problem hiding this comment.
+1. LGTM.
Leaving this PR for other reviewers to take another look.
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
SQLCancel was an unimplemented placeholder that unconditionally threw "SQLCancel is not implemented" (IM001), even though the underlying cancellation plumbing already existed. When Excel/Power BI try to cancel a long-running fetch and SQLCancel fails, they abandon the statement and resubmit the same query.
What changes are included in this PR?
This covers cancellation while fetching rows (the reported scenario). The initial query-execution RPC itself still can't be interrupted mid-flight -- Arrow's gRPC Flight transport doesn't expose a cancel hook for that unary call; that would need a separate transport-layer change.
Are these changes tested?
Yes. TestSQLCancelOnIdleStatement and TestSQLCancelDuringFetch, which failed (and crashed) before the fix, now pass -- tested against the mock server and manual verification through Excel.
Are there any user-facing changes?
No public API changes.
This PR contains a "Critical Fix". It fixes a crash (libc++abi terminating) caused by a stuck fetch thread with no way to be cancelled.
PR code and description written by:
Reviewed before submission by: