Skip to content

feat(session): add session version exchange - #331

Merged
aakash-saravanan-db merged 1 commit into
mainfrom
aakash-saravanan_data/fast-session-mode
Sep 17, 2026
Merged

aakash-saravanan-db merged 1 commit into
mainfrom
aakash-saravanan_data/fast-session-mode

Conversation

@aakash-saravanan-db

@aakash-saravanan-db aakash-saravanan-db commented Sep 9, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • request execution_mode=FAST by default when creating SQL Exec API sessions
  • track the maximum session_version observed from session creation, initial execution responses, and status/result responses attributable to the originating session
  • exclude attached or otherwise detached statement-ID operations from updating the current session
  • keep all traffic on the standard /api/2.0/sql path

Testing

  • cargo +stable fmt --all -- --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test (942 unit tests plus all enabled integration-test binaries; live tests ignored)

@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 clean, well-tested addition of session version exchange. The atomic version state is correctly scoped (one transport per session), fetch_max/has_session_version ordering is sound (no i64::MIN sentinel leaks), and both execute and metadata paths send-then-observe consistently while correctly excluding detached-statement polls. Wiremock coverage is solid. One Low note: FAST execution mode is now applied unconditionally to every session with no opt-out — intentional per the PR, but flagged for a reviewer's eye on warehouse compatibility.

Comment thread src/client/sea.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 — clean, well-tested change. The per-session transport lifetime makes the session_version atomic correctly session-scoped, and the observe/exclude split between session-owned polling (wait_for_completion) and detached statement-ID operations matches the PR intent, with wiremock coverage for create/execute exchange, missing-version tolerance, and the detached-poll exclusion. One low note on the 0 sentinel colliding with a potential legitimate version_id: 0.

Comment thread src/client/sea.rs
}

fn current_session_version(&self) -> Option<SessionVersion> {
let version_id = self.session_version.load(Ordering::SeqCst);

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 — The sentinel NO_SESSION_VERSION = 0 collides with a legitimate version_id of 0. current_session_version() treats any stored value equal to 0 as "no version observed" and returns None, so if the server ever reports session_version: { version_id: 0 }, observe_session_version will store it via fetch_max (max(0,0)=0) but the version will never be echoed back on subsequent execute requests — it is indistinguishable from the unset state. This is harmless if server-assigned versions are always positive (which appears to be the intent), but the assumption is undocumented and unenforced. Consider using Option<i64> behind an atomic guard, an i64::MIN sentinel, or a comment/assert documenting that version_id == 0 is reserved.

Minor, and likely never hit in practice — flagging only so the sentinel invariant is a conscious decision rather than an implicit one.

@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 — clean, well-tested session-version exchange. Version threading (create/execute/status), Current-vs-Detached attribution via the owning flag, fetch_max monotonicity, and omit-when-absent wire behavior are all correct and covered by wiremock + unit tests. One low note: execution_mode=FAST is now hardcoded on every session with no opt-out — fine if SEA ignores it on older servers, worth a confirmation.

Comment thread src/client/sea.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.

Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
@aakash-saravanan-db
aakash-saravanan-db force-pushed the aakash-saravanan_data/fast-session-mode branch from aeb28bb to 00c3498 Compare September 17, 2026 03:21

@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. Session-version exchange is wired correctly: owned execute/submit/direct/metadata paths (all through call_execute_api) send and observe the version, while status polls observe only under SessionAttribution::Current, and ExecutedAsyncStatement maps owning→Current/attached→Detached conservatively. fetch_max over the sentinel-0 baseline is monotonic and matches the documented protocol (FAST versions start at 1). One low note on missing live e2e coverage for the new FAST-mode behavior.

Comment thread src/client/sea.rs
catalog: catalog.map(|s| s.to_string()),
schema: schema.map(|s| s.to_string()),
session_confs: session_config,
execution_mode: SessionExecutionMode::Fast,

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 — Requesting execution_mode=FAST on every session and negotiating session_version is a live-server behavior change, but coverage is entirely wiremock/unit. Per repo guidance, a live behavior change warrants an #[ignore] tests/v0_*_e2e.rs case so the FAST/version handshake is validated against a real warehouse (the wire-shape mocks can't catch a server that rejects execution_mode or versions statements differently). Consider adding one. The wiremock coverage here is otherwise thorough — this is a gap only in live validation.

@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 session-version-exchange logic is correct. The session_version atomic is per-Session (one SeaRestTransport per Session::open), fetch_max keeps it monotonic under concurrent statements, wire compat is preserved via skip_serializing_if on the request field, and every Transport::statement_status/fetch_completed_result caller passes the right SessionAttribution (owning→Current, adopted/attached ids→Detached) so detached polls can't advance this session. Tests cover the create/execute exchange, absent-version, and detached-exclusion cases. One non-blocking note: an unrelated rustls RUSTSEC suppression is bundled in (see inline).

Comment thread osv-scanner.toml Outdated
reason = "h2 (RUSTSEC-2026-0258) DoS is a server-side empty-DATA-frame flood; the kernel is an HTTP client only and runs no h2 server. Transitive via reqwest/hyper, pre-existing on main, latest 0.4.x so no bump available. Re-review on expiry."

[[IgnoredVulns]]
id = "RUSTSEC-2026-0285"

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 PR bundles an unrelated supply-chain change: a new [[IgnoredVulns]] exception for RUSTSEC-2026-0285 (rustls) that the PR title/description ("add session version exchange") does not mention. The suppression itself is well-reasoned and time-boxed (ignoreUntil = 2026-09-22, ~5 days out from the current date), but folding an advisory exception into an unrelated feature PR makes it easy to miss in review and hard to bisect later. Consider splitting it into its own PR, or at minimum calling it out in the PR description so the security-advisory decision has an explicit audit trail.

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

@aakash-saravanan-db
aakash-saravanan-db added this pull request to the merge queue Sep 17, 2026
Merged via the queue into main with commit 5ea1da4 Sep 17, 2026
21 of 22 checks passed

This branch was previously deployed

1 inactive deployment
azure-prod — af78ef55 Deployed Sep 17, 2026 by aakash-saravanan-db via v0 TLS (mitmproxy) #737
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.

2 participants