Skip to content

feat(statement): enforce timeout across async polling - #374

Merged
jay-xiao446 merged 10 commits into
mainfrom
jay/kernel-async-query-timeout
Oct 2, 2026
Merged

jay-xiao446 merged 10 commits into
mainfrom
jay/kernel-async-query-timeout

Conversation

@jay-xiao446

@jay-xiao446 jay-xiao446 commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • add Statement::submit_with_timeout(Duration) in src/statement/mutable.rs while preserving existing submit() behavior
  • retain one monotonic client deadline on ExecutedAsyncStatement across status() and await_result() polling
  • keep kernel_statement_submit_with_timeout_ms as a thin duration-conversion adapter over the Rust API
  • return Timeout / HYT00 with query ID and schedule bounded best-effort cancel/close cleanup on expiry

Scope

The deadline covers initial submit through observed terminal status. Result materialization and fetching remain outside the query-execution timeout, matching synchronous execution. Zero and Duration::MAX explicitly mean unlimited.

Tests

  • cargo +stable fmt --all
  • cargo clippy --all-targets -- -D warnings
  • cargo test

@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 Medium · 1 Low

Solid, well-tested addition — the deadline plumbing, HYT00/query-id contract, and grace-window logic are sound. One medium concern: post-timeout status polls re-dispatch server cancel/close cleanup on every call because dispatch_timeout_cleanup isn't idempotent (telemetry finalize is). One low note on the submit-path expiry not scheduling cleanup, diverging from the header's documented contract.

Comment thread src/c_abi/statement.rs Resolved
Comment thread src/c_abi/statement.rs Resolved

@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 — the timeout enforcement is correctly threaded through submit and both async poll paths. One monotonic deadline is retained on the handle, poll paths check it with a bounded status grace, client_query_timeout_error carries Timeout/HYT00/query-id, telemetry finalize is idempotent, and cleanup dispatch is guarded by the client_timeout_expired swap so cancel/close fires at most once; cancel guards are defused on every expiry return to avoid a double-cancel. All three ExecutedAsyncStatement constructors were updated for the new client_deadline arg. Only a minor test-coverage gap (F1) and one cosmetic note. Nit: the as_ref()→as_mut() change at src/c_abi/statement.rs:959 is benign but unnecessary — the status handler only takes a *const reborrow of handle.exec and ExecutedAsyncStatement::status() takes &self, so no exclusive borrow is required.

Comment thread tests/v0_c_abi_canceller_wiremock.rs Resolved
@jay-xiao446 jay-xiao446 added the engineer-bot Apply to an issue to trigger the engineer-bot; on a PR to enable engineer follow-up label Oct 1, 2026
oss-engineer-bot Bot pushed a commit that referenced this pull request Oct 1, 2026
Addresses:
  - #4150147368 at src/c_abi/statement.rs:941
  - #4150250700 at tests/v0_c_abi_canceller_wiremock.rs:210

Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.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.

Verdict: 1 Medium · 1 Low

Solid, well-documented change; the deadline-policy mapping mirrors the sync path and is unit-tested. Two concerns: status() keeps enforcing the deadline even after a terminal status was already observed (returns a spurious Timeout and schedules cancel/close on a finished query — F1, medium), and the new await_result() deadline branches lack any test coverage (F2, low). Nit: the kernel_statement_submit prologue error messages were shortened from kernel_statement_submit: ... to statement submit: ..., dropping the exact entry-point name from the diagnostic — minor, no action needed.

Comment thread src/statement/executed_async.rs Resolved
Comment thread src/statement/executed_async.rs Resolved
oss-engineer-bot Bot pushed a commit that referenced this pull request Oct 1, 2026
Addresses:
  - #4161264557 at src/statement/executed_async.rs:490
  - #4161264563 at src/statement/executed_async.rs:604

Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.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.

Verdict: 1 Medium

Solid, well-tested PR — the deadline-policy mapping, cleanup latching, and telemetry idempotency all check out. One medium concern: await_result() omits the terminal_observed deadline exemption that status() applies, so it can mask an already-finished statement with a spurious Timeout/HYT00 and fire a wasted cancel/close.

Comment thread src/statement/executed_async.rs Resolved

@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

Solid, well-tested change — no correctness or convention concerns. The async deadline enforcement faithfully mirrors the sync wait_for_terminal gating (verified at src/client/sea.rs:550), telemetry finalize and cleanup dispatch are idempotent, and the C-ABI boundary matches the documented header contract. One low: the mid-submit timeout_at branch (distinct behavior: None query id, deliberately leaked statement) lacks test coverage, unlike its symmetric hung-status-poll counterpart.

Comment thread src/statement/mutable.rs Resolved

@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.

jay-xiao446 and others added 10 commits October 2, 2026 02:52
Signed-off-by: Jay Xiao <jay.xiao@databricks.com>
Addresses:
  - #4150147368 at src/c_abi/statement.rs:941
  - #4150250700 at tests/v0_c_abi_canceller_wiremock.rs:210

Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
Addresses:
  - #4160807790 at src/statement/mutable.rs:555

Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
Addresses:
  - #4161027160 at src/statement/executed_async.rs:250

Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
Addresses:
  - #4161140038 at src/c_abi/statement.rs:959

Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
Addresses:
  - #4161264557 at src/statement/executed_async.rs:490
  - #4161264563 at src/statement/executed_async.rs:604

Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
Addresses:
  - #4161264563 at src/statement/executed_async.rs:634

Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
Addresses:
  - #4161406588 at src/statement/executed_async.rs:634

Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
Addresses:
  - #4161511147 at src/statement/mutable.rs:497

Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
Signed-off-by: Jay Xiao <jay.xiao@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.

Verdict: 1 Low

Looks good — the client-timeout-across-async-polling change is correct and well-tested. One low note on the breadth of the new crate-wide clippy::double_must_use allow. The deadline policy mirrors the sync gating, all timeout exits defuse the cancel guard, cleanup dispatch and telemetry finalize are both idempotent, and the terminal-observed latch correctly scopes the deadline to the pre-terminal window; mid-submit expiry's lack of a targetable id is inherent and clearly documented.

Comment thread src/lib.rs
// `async_trait` marks its generated boxed futures as `must_use`. Rust 1.99's
// `double_must_use` lint also sees the `Future` trait's own annotation, so all
// async trait methods otherwise fail Clippy despite having the intended
// must-use behavior.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Low — This crate-level inner attribute suppresses clippy::double_must_use across the entire crate, not just the async_trait-generated methods the comment describes. The explanation is sound for the async-trait false positive, but a crate-wide blanket allow will also silence any genuine future double-#[must_use] on non-async-trait items. Consider scoping it more narrowly (e.g. on the trait definitions / modules that actually trip the lint) so legitimate occurrences elsewhere still surface. Non-blocking — the allow is documented and defensible given how pervasively async_trait is used here.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Keeping the crate-level #![allow(clippy::double_must_use)] as-is (src/lib.rs:21). The double_must_use false positive is triggered by #[async_trait], which is applied to 18+ trait definitions spread across ~12 modules (src/config.rs, src/client/{sea,transport}.rs, src/statement/{handle,executed,executed_async}.rs, src/reader/** including mod.rs, inline/streaming.rs, cloudfetch/*, post_processor/mod.rs, src/metadata/thrift_shape.rs, src/telemetry/statement.rs). Scoping the allow per-trait/per-module would mean scattering the same attribute across all of those sites — a much larger and more fragile diff than the single documented crate-level allow, and it would have to be re-added each time a new async trait is introduced. The risk the comment flags (silencing a genuine future double-#[must_use]) is low: the crate has no legitimate double-must_use items today, and this is a Rust 1.99 lint interaction with async_trait's generated code rather than something we'd want to catch on our own items. Given the reviewer flagged this as Low/non-blocking and "defensible," I'm leaving the broad allow in place with its explanatory 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.

Fair points on the maintenance cost — scattering the attribute across 18+ async traits in a dozen modules, and re-adding it per new trait, is a real downside, and I agree the risk of masking a genuine double-#[must_use] is low today. Since no code change was made and the crate-wide allow remains in place, I'll leave this open rather than auto-resolve: it's a Low/non-blocking tradeoff that a human can close with a glance. If a future must_use item on a non-async-trait type ever does get silently swallowed, this thread is the breadcrumb back to the decision. No further action needed from your side.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⛔ NEEDS HUMAN DECISION — the bots can't resolve this thread; a maintainer's input is required.

Thread has converged: reviewer flagged the crate-wide #![allow(clippy::double_must_use)] as Low/non-blocking, accepted the maintenance-cost rationale for not scoping it per-trait across 18+ async traits in ~12 modules, agreed the masking risk is low today, and explicitly stated no further action is needed — leaving it open deliberately as a breadcrumb for a human to close. No code change is warranted and no live question remains, so flagging for human close rather than continuing the exchange.

This branch was previously deployed

1 inactive deployment
azure-prod — 5653e36b Deployed Oct 2, 2026 by oss-engineer-bot[bot] via followup #1871
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

engineer-bot Apply to an issue to trigger the engineer-bot; on a PR to enable engineer follow-up

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants