Skip to content

[SPARK-56252][HISTORY] History server disk store lease should remove temp path delete hook after commit and rollback to avoid memory leak#54947

Open
LennonChin wants to merge 2 commits intoapache:masterfrom
LennonChin:patch-1
Open

Conversation

@LennonChin
Copy link
Copy Markdown

What changes were proposed in this pull request?

In the History Server DiskManager, when acquiring a lease, a temporary directory is created on the disk, and a JVM shutdown hook is registered used to remove this temporary directory. When the lease is committed or rolled back, the temporary directory is either renamed to the target directory or deleted, but the registered JVM shutdown hook remains in the ShutdownHookManager, causing a memory leak. Additionally, a large number of residual hooks will execute when the History Server restarts, severely slowing down the restart process.

Why are the changes needed?

We should remove residual hooks when lease committed or rolled back.

Does this PR introduce any user-facing change?

How was this patch tested?

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

…fter commit and rollback to avoid memory leak
@LennonChin LennonChin changed the title History server disk store lease should remove temp path delete hook after commit and rollback to avoid memory leak [HISTORY] History server disk store lease should remove temp path delete hook after commit and rollback to avoid memory leak Mar 23, 2026
@LennonChin
Copy link
Copy Markdown
Author

gently ping @sunchao @pan3793

val newSize = sizeOf(tmpPath)
makeRoom(newSize)
tmpPath.renameTo(dst)
ShutdownHookManager.removeShutdownDeleteDir(tmpPath)
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.

You may need to check the return value of tmpPath.renameTo(dst) - File.renameTo returns true iff the renaming succeeded; false otherwise.

@pan3793
Copy link
Copy Markdown
Member

pan3793 commented Mar 27, 2026

@LennonChin, this makes sense, please fill a Jira ticket and complete the PR description.

@LennonChin LennonChin changed the title [HISTORY] History server disk store lease should remove temp path delete hook after commit and rollback to avoid memory leak [SPARK-56252][HISTORY] History server disk store lease should remove temp path delete hook after commit and rollback to avoid memory leak Mar 27, 2026
@LennonChin LennonChin requested a review from pan3793 March 27, 2026 08:18
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