Skip to content

[SPARK-58714][SS] Fix AdminClient leak in KafkaTokenUtil.obtainToken - #57953

Open
pan3793 wants to merge 1 commit into
apache:masterfrom
pan3793:kafka-admin-client-leak
Open

[SPARK-58714][SS] Fix AdminClient leak in KafkaTokenUtil.obtainToken#57953
pan3793 wants to merge 1 commit into
apache:masterfrom
pan3793:kafka-admin-client-leak

Conversation

@pan3793

@pan3793 pan3793 commented Aug 12, 2026

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

Wrap the token acquisition in KafkaTokenUtil.obtainToken in try/finally so the created AdminClient is always closed, via Utils.closeQuietly.

Why are the changes needed?

obtainToken creates an AdminClient but never closes it, on either the success or the exception path. Each token obtain (per cluster, per renewal cycle) and each failed attempt leaks the client's network thread and sockets, which accumulate in long-running drivers.

Present since the feature was introduced in SPARK-25501 (Spark 3.0.0).

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Existing tests (KafkaTokenUtilSuite).

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

Generated-by: Claude Code (claude-fable-5)

@pan3793

pan3793 commented Aug 12, 2026

Copy link
Copy Markdown
Member Author

cc @gaborgsomogyi @HeartSaVioR

@uros-b

uros-b commented Aug 12, 2026

Copy link
Copy Markdown
Member

Thank you @pan3793!

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