Skip to content

fix(kernel): evict invalid sessions and reject reuse - #595

Merged
vuanhphung merged 2 commits into
mainfrom
fix/kernel-evict-expired-session
Nov 26, 2026
Merged

vuanhphung merged 2 commits into
mainfrom
fix/kernel-evict-expired-session

Conversation

@vuanhphung

@vuanhphung vuanhphung commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

SEA reports unusable sessions as either 404 Session does not exist or 400 Invalid SessionHandle. Recognize both while preserving unrelated NotFound and InvalidArgument errors.

Return the original error for the request that discovers the dead session to prevent automatic replay. Reject later execution on an invalid session with ErrBadConn before calling the kernel, so pinned *sql.Conn instances are retired too.

Validation: full pure-Go and kernel-tagged test suites pass. Regression tests use a local SEA endpoint to verify both response shapes, no replay of the failed statement, and no additional statement requests from pinned connections. Standard lint and tagged lint for changed code pass; two pre-existing unchecked r.Close() calls remain in rows.go.

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

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

@vuanhphung vuanhphung changed the title fix(kernel): evict connections for missing sessions fix(kernel): evict invalid sessions and reject reuse Nov 24, 2026

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

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

@vuanhphung
vuanhphung force-pushed the fix/kernel-evict-expired-session branch from 3ff8550 to ebab7ff Compare November 26, 2026 04:13

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

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

Verdict: 1 Nit

Looks good, with no blocking concerns. The classifier is narrowed by status code before it matches the message text. The Execute guard only blocks requests that have not been sent yet, and the namespace setup uses the internal execute, so it skips the guard. The tests cover both server response shapes, no replay of the failed statement, and no extra requests from pinned connections.

Other findings

  • ⚪ Nit — isSessionFatal detects dead sessions by matching server message substrings, so rewording on the SEA side would silently stop eviction. Match on a structured error code or reason if the kernel exposes one, and keep the message tests as a regression guard. (Found by Claude Opus 5.5 · confirmed by the judge)

@vuanhphung
vuanhphung enabled auto-merge November 26, 2026 04:18
@vuanhphung
vuanhphung added this pull request to the merge queue Nov 26, 2026
@vuanhphung vuanhphung added the skip-coverage Skip the coverage fan-out for this PR (no tracking issue opened in databricks-driver-test) label Nov 26, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 26, 2026
@vuanhphung
vuanhphung force-pushed the fix/kernel-evict-expired-session branch from ebab7ff to 1ad0563 Compare November 26, 2026 04:37
@vuanhphung
vuanhphung enabled auto-merge November 26, 2026 04:37

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

🔀 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 sound, with 1 medium concern. Matching the session-handle errors is narrow and well tested, and the new local ErrBadConn rejection happens before anything is sent. However, that rejection also hits pinned connections after transient Unavailable/NetworkError failures.

// parameters (req.Params) are bound onto the statement in execute (see
// bindParams).
func (k *KernelBackend) Execute(ctx context.Context, req backend.ExecRequest) (backend.Operation, error) {
if !k.valid {

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 !k.valid guard in Execute fires for every isSessionFatal code, including transient Unavailable/NetworkError/Unauthenticated, so a pinned conn whose server session is still alive now gets ErrBadConn forever. The CHANGELOG describes only missing or invalid sessions. Use a separate flag for definite session loss, or document the wider behavior and add a test for it.

🔀 Found by Claude Opus 5.5 · confirmed by the judge

@vuanhphung
vuanhphung added this pull request to the merge queue Nov 26, 2026
Merged via the queue into main with commit 319b145 Nov 26, 2026
16 checks passed
@vuanhphung
vuanhphung deleted the fix/kernel-evict-expired-session branch November 26, 2026 04:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted skip-coverage Skip the coverage fan-out for this PR (no tracking issue opened in databricks-driver-test)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants