Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(fs): close directory file descriptor #207

Merged
merged 1 commit into from
Apr 12, 2023

Conversation

andrewazores
Copy link
Member

@andrewazores andrewazores commented Apr 12, 2023

Related to https://github.com/cryostatio/cryostat/issues/1444

The FileSystem wrapper around java.nio.file.Files fails to close the Stream<Path> it opens when listing directory contents. This class is dependency-injected in Cryostat (for testing mock ease) and used in several frequently called codepaths. This leaking fd adds up quite quickly as Cryostat runs and serves requests.

To test/verify, try the following:

$ sh smoketest.sh # in first terminal
$ podman ps --ns # in second terminal here and next commands. Note the PID of the cryostat container
$ watch 'ls -l /proc/$pid/fd | wc -l' # replace $pid with the PID from above
$ xdg-open https://localhost:8181 # click around the UI, particularly click back and forth between Recordings, Archives, and other clientside views. Watch the open fd count in the second terminal grow

Then check out this PR, mvn install it, update the Cryostat pom.xml to use the updated -core, rebuild the container and re-run the test. There is another fd leak (I think in the Cryostat server-side code, checking on it still) that grows much more slowly, but with this leak fixed the number should grow much more slowly than previously.

Copy link
Member

@tthvo tthvo left a comment

Choose a reason for hiding this comment

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

Looks good! Fixed the issue!

@andrewazores andrewazores merged commit 161ad4a into cryostatio:main Apr 12, 2023
@andrewazores andrewazores deleted the file-descriptors branch April 12, 2023 18:02
Josh-Matsuoka pushed a commit to Josh-Matsuoka/cryostat-core that referenced this pull request Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants