Repository navigation
Avoid waiting for cleanup of drained async statements - #507
vuanhphung wants to merge 17 commits into
Conversation
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 2 Nit
Looks good: 2 low concerns. The drained-close detach logic, the drain signal's error handling and the Drop refactor all look correct, and the tests cover the mock-server and live-warehouse paths.
Other findings
- ⚪ Nit — napi/index.d.ts is the generated binding file and still carries the old close() doc, because the Rust doc comment changed in this PR without regenerating it. Regenerate index.d.ts, or edit it by hand, and commit it. (Found by Claude Opus 5.5 · confirmed by the judge)
- ⚪ Nit — The new tests/v0_async_close_logging_wiremock.rs starts directly with
useand has no Apache 2.0 license header. Every sibling test file begins with// Copyright (c) 2026 Databricks, Inc.and the license block. Add the standard header. (Found by Claude Opus 5.5 · confirmed by the judge)
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Low · 1 Nit
Looks good, with 2 low concerns. Background cleanup after a drained close is gated correctly on the closed swap and the DeleteSession result, and the same-session wait lets status fall through to GET on timeout or failure. Test coverage is thorough at the unit, wiremock and e2e levels.
Other findings
- ⚪ Nit — Tests named
reviewer_*printREVIEWER ...diagnostics with eprintln! on every run, which looks like leftover review-harness debugging. Rename the tests after the behavior they pin and remove the eprintln! calls. (Found by Claude Opus 5.5 · confirmed by the judge)
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
|
Fixed the test-harness nit in bd95fd5: renamed the three reviewer-prefixed tests by behavior and removed the REVIEWER eprintln! diagnostics; assertions remain. This comment was generated with GitHub MCP. |
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 2 Low
Mostly solid: 1 medium and 1 low concern. The drained-close detach and the per-session completion registry look correct and are well tested. The concerns are how long same-session status can wait on a retrying DELETE, and close-failure warnings staying at DEBUG after a failed session close.
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Low
Mostly solid, with 1 medium concern. Drained close now detaches cleanup correctly, with good wiremock and e2e coverage. The new same-session wait-for-cleanup is bounded only by the HTTP overall timeout, so it can stall status polling for a long time.
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Low
Looks good, with 2 low concerns. Drained close detaches its cleanup correctly. In-flight closes are deduplicated per session, same-session status/attach wait for cleanup with a time bound, and the wiremock, unit and e2e tests cover the new paths.
This overview is Claude Opus 5.5's initial take; some of its points were set aside by the cross-check judge — see the findings below.
🔀 1 finding considered and dismissed by the judge
- 🔵 Low
src/session.rs:887—Session::closesetsclose_initiatedto true beforedelete_sessionruns, and nothing resets it if the call fails.closedstays false, so the session is s
Judge's evidence:pub async fn close(self) -> Result<()> {
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Low
Looks solid overall, with 1 medium concern. The same-session wait only covers attach and status, so result polling on attached handles can still race the background DELETE.
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Low
Looks good, with 1 low concern. The drained-close detach, the per-session dedup of in-flight closes and the bounded same-session waits look sound, and wiremock, unit and e2e tests cover them.
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
✅ No issues identified.
🔀 1 finding considered and dismissed by the judge
- 🔵 Low
src/session.rs:118—waitdrops thetokio::time::timeoutresult withlet _, so if the cleanup budget runs out, attach/status quietly reads server state that can still show SUC
Judge's evidence:let _ = tokio::time::timeout(budget, completion.changed()).await;
|
Closing: this only speeds up an explicit close() on a drained async result, which none of the connector benchmarks time, and it changes cleanup semantics. Not worth the added complexity. |
Description
After an async result is fully read,
close()no longer waits for the CloseStatement round trip: it releases the handle and sends the DELETE in the background. Closing an undrained result still waits. Independent of #459 and #472.To keep close-then-state callers correct (for example the Python connector's
close_command→get_query_state), same-session attach/status and the owner'sawait_result()/fetch_result()wait for that DELETE before reading server state, so they still see CLOSED. Drop stays fire-and-forget, as on main.Behavior changes:
Session::close, statements skip CloseStatement. If DeleteSession failed, a still-running dropped statement isn't cancelled; the server reclaims it with the session at idle timeout.Testing
SELECT 1, live warehouse, median (p90)close()n=30 per variant in fresh processes with rotated order; no WARN/ERROR lines. Measured at 2388a85; later commits don't touch the drained-close path, and a rerun at 679d21a matched.
Unit, wiremock (DELETE held until the test releases it; 0 failures under concurrent load), napi, pyo3 and live async e2e tests pass. The Python connector's close → state reads CLOSED 10/10. Removing any of the new waits, the closed-session skip or the log-level choice fails a test.
Adversarial review: 3 rounds, converged; review bot approved 35e709b.
This pull request and its description were written by Isaac.