Skip to content

GH-1067: Close cached HDFS FileSystem instances - #1141

Open
xborder wants to merge 3 commits into
apache:mainfrom
xborder:gh-1067
Open

GH-1067: Close cached HDFS FileSystem instances#1141
xborder wants to merge 3 commits into
apache:mainfrom
xborder:gh-1067

Conversation

@xborder

@xborder xborder commented May 7, 2026

Copy link
Copy Markdown
Contributor

What's Changed

  • This PR fixes JVM shutdown hangs after reading HDFS datasets through Arrow Java.
  • FileSystemDatasetFactory now tracks hdfs:// URIs used to create the factory. On close(), after releasing the native dataset factory, it best-effort closes the matching Hadoop FileSystem instances.
  • The Hadoop cleanup is done via reflection so Arrow Java does not add a production dependency on Hadoop. Non-HDFS URIs are ignored.

Closes #1067 .

@github-actions

This comment has been minimized.

@jbonofre jbonofre added this to the 20.0.0 milestone May 7, 2026
@jbonofre jbonofre added the bug-fix PRs that fix a big. label May 7, 2026
@jbonofre

Copy link
Copy Markdown
Member

@xborder I fixed the CI on main. Can you please rebase?

@lidavidm

Copy link
Copy Markdown
Member

Sorry, probably need to rebase again.

@xborder

xborder commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

done @lidavidm

Comment on lines +73 to +77
try {
super.close();
} finally {
hdfsFileSystems.forEach(FileSystemDatasetFactory::closeHadoopFileSystem);
}

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.

nit: could we use AutoCloseables here?

@xborder xborder Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think we could use AutoCloseables by casting the Object obtained through reflection, but it would not simplify or improve the cleanup logic.

Is there any benefit in changing it that I'm not seeing?

Comment thread dataset/src/main/java/org/apache/arrow/dataset/file/FileSystemDatasetFactory.java Outdated
Comment thread dataset/src/main/java/org/apache/arrow/dataset/file/FileSystemDatasetFactory.java Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix PRs that fix a big.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ARROW Java][HDFS] JVM hangs after reading HDFS files via Arrow Dataset API due to non-daemon native threads

3 participants