Skip to content

[CONNECT] Isolate cleanup of native JVM query and session owners - #902

Draft
dbtsai wants to merge 1 commit into
apache:masterfrom
dbtsai:codex/native-connect-isolated-owner-cleanup
Draft

dbtsai wants to merge 1 commit into
apache:masterfrom
dbtsai:codex/native-connect-isolated-owner-cleanup

Conversation

@dbtsai

@dbtsai dbtsai commented Nov 20, 2026

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

A stalled Java query or session close currently blocks every later close of the same type through a process-wide JNI cleanup queue. Those unrelated owners retain their handles and admission permits while waiting.

Give each query and session its own cleanup worker, using the existing attachment, detach and shutdown accounting. Failed dispatch and cleanup retain ownership for explicit retry. Task cancellation and task frees continue to share their existing worker.

Each query/session close now costs a thread spawn and, during normal cleanup, a JNI attach/detach instead of shared-worker burst reuse. If a closer cannot start, its handles and permits remain retained until an explicit server close retries cleanup. Blocked owners remain bounded by per-engine admission; threads and attachments finishing completed closes can overlap later admission.

Follow-up to #474.

Why are the changes needed?

Prevent an indefinitely blocked close from delaying unrelated queries and sessions in this experimental server.

Does this PR introduce any user-facing change?

Yes. Unrelated query/session cleanup can now reclaim admission while a peer close remains blocked.

How was this patch tested?

Validation rerun for this follow-up on macOS ARM64 with JDK 21 and the pinned Spark 4.2.0-SNAPSHOT runtime: JNI Rust tests, workspace formatting/Clippy, license freshness, the release native build and real JNI smoke under -Xcheck:jni.

Earlier in this follow-up, the client, frontend and C sources at base 32b27eb passed the following checks; these were not repeated after the JNI-only review fixes: frontend Rust tests, release client unit tests, full integration compilation with and without WASM, and C ownership checks with ASan/UBSan. Hosted CI remains pending.

Added Rust regressions cover blocked-owner isolation across engines and closer-start failure with retry using injected blocking/failures. The real JVM smoke covers normal closes.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: OpenAI Codex (GPT-6)

This pull request and its description were written by OpenAI Codex.

Prevent a blocked Java close from delaying unrelated owners through global cleanup queues. Preserve attachment accounting and retained ownership for failed-cleanup retry.

Generated-by: OpenAI Codex

This branch has not been deployed

No deployments
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