RekTai opened a new pull request, #55950:
URL: https://github.com/apache/arrow/pull/55950
### 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: #55790
Thanks for opening a pull request!
If this is your first pull request you can find detailed information on how
to contribute here:
* [New Contributor's
Guide](https://arrow.apache.org/docs/dev/developers/guide/step_by_step/pr_lifecycle.html#reviews-and-merge-of-the-pull-request)
* [Contributing
Overview](https://arrow.apache.org/docs/dev/developers/overview.html)
Please remove this line and the above text before creating your pull request.
### Rationale for this change
### What changes are included in this PR?
### Are these changes tested?
### Are there any user-facing changes?
**This PR includes breaking changes to public APIs.** (If there are any
breaking changes to public APIs, please explain which changes are breaking. If
not, you can remove this.)
**This PR contains a "Critical Fix".** (If the changes fix either (a) a
security vulnerability, (b) a bug that caused incorrect or invalid data to be
produced, or (c) a bug that causes a crash (even when the API contract is
upheld), please provide explanation. If not, you can remove this.)
### Was AI used for this PR?
In accordance to the [AI generation
guidelines](https://arrow.apache.org/docs/dev/developers/overview.html#ai-generated-code),
please disclose below whether and how AI was used in this PR.
**PR code and description written by:**
- [ ] Human
- [ ] AI
**Reviewed before submission by:**
- [ ] Human
- [ ] AI
- [ ] Not reviewed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]