HDDS-11811. rocksdbjni deleted on exit could be used by other components #7493
+57
−22
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
NativeLibraryLoader
copies the library being loaded to the directory defined bynative.lib.tmp.dir
property (e.g./tmp
). It uses a temporary file name as target to avoid conflicts. It also copies some dependencies, whose names are preserved to ensure library links are not broken. All libs are deleted when the process exits.Multiple Ozone processes running on the same host all copy libs to the same path (
/tmp/librocksdbjni-linux64.so
). Copying and deleting both introduce race conditions, causing other processes to see incomplete or no file at all.This PR fixes the problem by creating a temporary dir with unique name, and copying all libs with original name to that dir.
https://issues.apache.org/jira/browse/HDDS-11811
How was this patch tested?
Updated unit test case.
Built locally with native libs.
CI:
https://github.com/adoroszlai/ozone/actions/runs/12039265661