Skip to content

Fix HoodieStorage resource leak in FileSystemBasedLockProvider.close()#18461

Open
mailtoboggavarapu-coder wants to merge 1 commit intoapache:masterfrom
mailtoboggavarapu-coder:fix/filesystem-lock-provider-storage-leak
Open

Fix HoodieStorage resource leak in FileSystemBasedLockProvider.close()#18461
mailtoboggavarapu-coder wants to merge 1 commit intoapache:masterfrom
mailtoboggavarapu-coder:fix/filesystem-lock-provider-storage-leak

Conversation

@mailtoboggavarapu-coder
Copy link
Copy Markdown
Contributor

Problem

FileSystemBasedLockProvider creates a HoodieStorage instance in its constructor but never closes it in the close() method. Since HoodieStorage implements Closeable and holds underlying filesystem connections, this causes a resource leak every time the lock provider is closed.

Solution

Add a finally block inside close() to ensure storage.close() is always called after the lock file deletion attempt, regardless of whether deletion succeeds or throws an exception. IOException from storage.close() is caught and logged as a warning to avoid masking the original exception.

Changes

  • FileSystemBasedLockProvider.java: Added finally block in close() to call storage.close() with proper exception handling.

@github-actions github-actions bot added the size:XS PR with lines of changes in <= 10 label Apr 3, 2026
@hudi-bot
Copy link
Copy Markdown
Collaborator

hudi-bot commented Apr 3, 2026

CI report:

Bot commands @hudi-bot supports the following commands:
  • @hudi-bot run azure re-run the last Azure build

Copy link
Copy Markdown
Contributor Author

@mailtoboggavarapu-coder mailtoboggavarapu-coder left a comment

Choose a reason for hiding this comment

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

Pinging for an initial review. This PR fixes a genuine resource leak: FileSystemBasedLockProvider creates a HoodieStorage (which holds underlying filesystem connections and implements Closeable) in its constructor but never closes it in close(). The fix is a one-liner — calling storage.close() inside the existing close() method so the resource is released every time the lock provider is torn down.

Would appreciate a review from a committer with write access to apache/hudi (@vinothchandrasekar / @alexeykudinkin / @danny0405 / @nsivabalan).

try {
storage.close();
} catch (IOException e) {
LOG.warn("Failed to close storage in FileSystemBasedLockProvider", e);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

good catch, can you fix the indentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS PR with lines of changes in <= 10

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants