Skip to content

[SPARK-44462][FOLLOWUP][SS][CONNECT] Assert foreachBatch close() unregisters the cloned session - #59202

Closed
LuciferYang wants to merge 1 commit into
apache:masterfrom
LuciferYang:SPARK-44462-assert-cloned-session-unregister
Closed

LuciferYang wants to merge 1 commit into
apache:masterfrom
LuciferYang:SPARK-44462-assert-cloned-session-unregister

Conversation

@LuciferYang

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Followup to #55410. The two ForeachBatchSessionManager cleanup tests in StreamingForeachBatchHelperSuite checked that close() is terminal and that the registered cleaner runs, but neither asserted the side effect close() exists to guarantee: that the cloned SessionHolder is removed from SparkConnectService.sessionManager. Because close() sets its closed flag independently of the closeSession call, a future change that dropped or broke the unregister step would still pass both tests while re-introducing the never-expiring-holder leak. This adds assertions that the cloned SessionKey is present in the session manager before close() and absent after.

Why are the changes needed?

To make the cloned-session leak-prevention contract regression-sensitive. Spotted in review of #59200, the branch-4.3 backport.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Pass GitHub Actions.

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

Generated-by: Claude Code

@LuciferYang

Copy link
Copy Markdown
Contributor Author

cc @HyukjinKwon

@uros-b uros-b left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for following up on this!

LuciferYang added a commit that referenced this pull request Oct 2, 2026
…gisters the cloned session

### What changes were proposed in this pull request?

Followup to #55410. The two `ForeachBatchSessionManager` cleanup tests in `StreamingForeachBatchHelperSuite` checked that `close()` is terminal and that the registered cleaner runs, but neither asserted the side effect `close()` exists to guarantee: that the cloned `SessionHolder` is removed from `SparkConnectService.sessionManager`. Because `close()` sets its `closed` flag independently of the `closeSession` call, a future change that dropped or broke the unregister step would still pass both tests while re-introducing the never-expiring-holder leak. This adds assertions that the cloned `SessionKey` is present in the session manager before `close()` and absent after.

### Why are the changes needed?

To make the cloned-session leak-prevention contract regression-sensitive. Spotted in review of #59200, the branch-4.3 backport.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Pass GitHub Actions.

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

Generated-by: Claude Code

Closes #59202 from LuciferYang/SPARK-44462-assert-cloned-session-unregister.

Lead-authored-by: YangJie <yangjie01@baidu.com>
Co-authored-by: reviewer <reviewer@local>
Signed-off-by: yangjie01 <yangjie01@baidu.com>
(cherry picked from commit 38422ae)
Signed-off-by: yangjie01 <yangjie01@baidu.com>
@LuciferYang

Copy link
Copy Markdown
Contributor Author

Merge Summary:

Posted by merge_spark_pr.py

@LuciferYang

Copy link
Copy Markdown
Contributor Author

Thank you @HyukjinKwon @uros-b

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.

3 participants