Repository navigation
feat(c-abi): cooperative cancel token for blocking calls - #166
Closed
mani-mathur-arch wants to merge 1 commit into
Closed
mani-mathur-arch wants to merge 1 commit into
mani-mathur-arch wants to merge 1 commit into
Conversation
mani-mathur-arch
changed the base branch from
mani/c-abi-pupr-statement-surface
to
main
July 19, 2026 08:57
mani-mathur-arch
force-pushed
the
mani/c-abi-cancel-token
branch
from
July 19, 2026 08:58
e32c953 to
803734e
Compare
mani-mathur-arch
temporarily deployed
to
azure-prod
July 19, 2026 08:58 — with
GitHub Actions
Inactive
mani-mathur-arch
temporarily deployed
to
azure-prod
July 19, 2026 08:58 — with
GitHub Actions
Inactive
Add kernel_cancel_token_t plus cancellable variants of the connect and result-fetch entry points, so a C-ABI host can interrupt an otherwise uninterruptible blocking call by a caller deadline: - kernel_session_open_cancellable - kernel_result_stream_next_batch_cancellable block_on_ffi_cancellable races the operation future against the token via a biased tokio::select!; a fire drops the in-flight future, aborting the underlying reqwest request (the crate's documented cancellation model), and yields a typed Cancelled. A NULL token routes to the identical plain-path behavior, so the default path and existing symbols are byte-for-byte unchanged. Token firing is purely local (no RPC), safe to call from another thread — modeled on the existing statement canceller. tokio_util's CancellationToken is already a crate dependency, so no new cargo-deny entry. Additive only — no existing symbol's layout or meaning changes, ABI unchanged. Tests: cancel unit tests (incl. the is_cancelled accessor), wiremock integration tests proving a mid-connect cancel returns Cancelled in under 5s against a 10s stalled server (plus NULL-token parity and pre-fired short-circuit), and C-smoke lifecycle + pre-fired short-circuit. make check green. Co-authored-by: Isaac Signed-off-by: Mani Kaustubh Mathur <mani.mathur@databricks.com>
mani-mathur-arch
force-pushed
the
mani/c-abi-cancel-token
branch
from
July 19, 2026 09:07
803734e to
eb55554
Compare
mani-mathur-arch
temporarily deployed
to
azure-prod
July 19, 2026 09:07 — with
GitHub Actions
Inactive
mani-mathur-arch
temporarily deployed
to
azure-prod
July 19, 2026 09:07 — with
GitHub Actions
Inactive
Contributor
Author
|
not needed |
This branch was previously deployed
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.
What
Add a cooperative cancel token to the kernel C ABI so a host (Go, ODBC) can interrupt an otherwise-uninterruptible blocking call by a caller deadline:
kernel_cancel_token_new/_cancel/_is_cancelled/_free— an opaqueCancellationTokena host fires from a watcher thread.kernel_session_open_cancellable(connect side) andkernel_result_stream_next_batch_cancellable(hung CloudFetch batch) — race the op against the token via a biasedtokio::select!; a fire drops the in-flight future (a realreqwestabort) and yieldsCancelled.A NULL token routes to the identical plain-path behavior, so the default path and existing symbols are byte-for-byte unchanged. Additive only — ABI unchanged.
tokio_util'sCancellationTokenis already a crate dep (no newcargo-denyentry).Closes the runtime-contract gaps PECOBLR-3645 (mid-fetch cancel) and the connect half of PECOBLR-3646 (session-lifecycle deadlines). The token is protocol-neutral and reused verbatim by the OSS ODBC driver (shared C-ABI gap).
Tests
cancel.rsunit tests (lifecycle incl. theis_cancelledaccessor, null guards).Cancelledin <5s against a 10s stalled server, NULL-token parity, and a directnext_batch_cancellablefetch-path test (pre-fired token short-circuits a real result stream; NULL token fetches normally).make checkgreen.Co-authored-by: Isaac