Skip to content

feat(c-abi): per-call deadline for kernel_session_test (odbc#347-C) - #310

Merged
vikrantpuppala merged 1 commit into
mainfrom
odbc-347c-connection-test-timeout
Sep 3, 2026
Merged

vikrantpuppala merged 1 commit into
mainfrom
odbc-347c-connection-test-timeout

Conversation

@vikrantpuppala

Copy link
Copy Markdown
Collaborator

Summary

Adds a per-call deadline to kernel_session_test so an ODBC host can actually enforce ConnectionTestTimeout (databricks/databricks-odbc#347, defect C).

Previously the SELECT 1 connection probe ran on the session's own retry/timeout budget, so ConnectionTestTimeout=1 and =30 behaved identically, and SQL_ATTR_CONNECTION_DEAD could block for the session's unrelated retry budget during an outage.

  • New timeout_secs parameter on kernel_session_test (0 = no per-call deadline, the historical behaviour).
  • Session::test_connection_with_timeout wraps the probe in tokio::time::timeout, bounding the whole probe (retries + HTTP included) and returning a Timeout-category error when it elapses. The bound is scoped to the probe future, so it never alters the timeout of other requests on the session.
  • Header (include/databricks_kernel.h, hand-written) updated to match.

Test plan

  • New wiremock test session_test_honours_per_call_timeout: a 1s deadline against a 20s response returns Timeout in ~1s, not ~20s.
  • Existing session_test_* wiremock tests updated to pass timeout_secs = 0 (unchanged behaviour).
  • cargo test --lib session, cargo fmt, cargo clippy --lib --tests clean.

Downstream

The ODBC driver's defect-C fix (databricks/databricks-odbc#347) consumes this: it passes the configured ConnectionTestTimeout as timeout_secs. The ODBC KERNEL_REPO_TAG must be bumped to this PR's merge commit.

This pull request and its description were written by Isaac.

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ No issues identified by the review bot.

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: 1 Low

Looks good — a focused, well-tested change. The C ABI signature bump is fully propagated (header, all wiremock callers, docs), ErrorCode::Timeout maps to KernelStatusCode::Timeout, Duration is already in scope, and tokio::time::timeout runs inside block_on_ffi's runtime. One low convention/consistency note on the timeout error construction.

Comment thread src/session.rs Resolved
@vikrantpuppala
vikrantpuppala added this pull request to the merge queue Sep 3, 2026
@vikrantpuppala
vikrantpuppala removed this pull request from the merge queue due to a manual request Sep 3, 2026
kernel_session_test previously ran its SELECT 1 probe on the session's own
retry/timeout budget, so a host backing ConnectionTestTimeout could not enforce
the configured duration — ConnectionTestTimeout=1 and =30 behaved identically,
and SQL_ATTR_CONNECTION_DEAD could block for the session's unrelated retry
budget during an outage.

Add a `timeout_secs` parameter (0 = no per-call deadline, the historical
behaviour). Session::test_connection_with_timeout wraps the probe in
tokio::time::timeout, bounding the whole probe (retries + HTTP included) to the
deadline and returning a Timeout-category error when it elapses. The bound is
scoped to the probe future, so it cannot alter the timeout of any other request
on the session.

Wiremock test: a 1s deadline against a 20s response returns Timeout in ~1s, not
~20s.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ No issues identified by the review bot.

@vikrantpuppala
vikrantpuppala added this pull request to the merge queue Sep 3, 2026
Merged via the queue into main with commit 1cfae59 Sep 3, 2026
21 of 22 checks passed

This branch was previously deployed

1 inactive deployment
azure-prod — c515ae6e Deployed Sep 3, 2026 by oss-reviewer-bot[bot] via followup #1254
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant