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

HDDS-10149. New JNI layer for RawSSTFileReader & RawSSTFileReaderIterator #6182

Merged
merged 40 commits into from
Feb 22, 2024

Conversation

swamirishi
Copy link
Contributor

@swamirishi swamirishi commented Feb 7, 2024

What changes were proposed in this pull request?

Including rocksdb in ozone_rocks_tools native library interferes with rocksdb lib loaded from rocksdbjni jar, which leads to issues like block checksum mismatch error. Bad file descriptor error. Instead of adding rocksdb static lib as static lib to ozone_rocks_tools adding rocksdb static lib as a shared lib should prevent such issues from occuring.
Changed the rocks tools build to use rocksdbjnlllib from rocksdb jar instead of building rocksdb from scratch.
Implemented RawSSTFileReader & RawSSTFileReaderIterator in rocksdb tools to implement an iterator in the native side to read tombstone entries.

https://issues.apache.org/jira/browse/HDDS-10149

How was this patch tested?

Refactored and changed existing unit testcases and integration tests.

@swamirishi swamirishi marked this pull request as ready for review February 14, 2024 02:34
@swamirishi swamirishi changed the title HDDS-10149. Fix native lib to not include rocksdb library as static library HDDS-10149. New JNI layer for RawSSTFileReader & RawSSTFileReaderIterator Feb 14, 2024
@adoroszlai adoroszlai marked this pull request as draft February 14, 2024 08:33
# Conflicts:
#	hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestSnapshotDiffManager.java
@swamirishi swamirishi marked this pull request as ready for review February 15, 2024 17:32
@swamirishi
Copy link
Contributor Author

The PR can be reviewed now. I have fixed all the issues with the patch.

Copy link
Contributor

@hemantk-12 hemantk-12 left a comment

Choose a reason for hiding this comment

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

Thanks @swamirishi for working on this.

Comment on lines 35 to 43
public static boolean loadLibrary() throws NativeLibraryNotLoadedException {
ManagedRocksObjectUtils.loadRocksDBLibrary();
if (!NativeLibraryLoader.getInstance()
.loadLibrary(ROCKS_TOOLS_NATIVE_LIBRARY_NAME)) {
throw new NativeLibraryNotLoadedException(
ROCKS_TOOLS_NATIVE_LIBRARY_NAME);
}
return true;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

  1. I think, this code should be moved to SnapshotDiffManager#initSSTDumpTool(). And in test should load lib wherever is needed in @BeforeAll. ManagedRawSSTFileReader class in itself doesn't care if native lib is loaded or not. And rely on the caller that they should load it before using it.

  2. May be call loadNativeLib rather than initSSTDumpTool.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

Choose a reason for hiding this comment

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

loadLibrary is still in ManagedRawSstFileReader. Please move it to SnapshotDiffManager.

It is responsibility of the SnapshotDiffManager to make sure native-lib is loaded before using optimized SnapDiff.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No I believe this particular piece should reside in this particular module since this class cannot run without the library being loaded. It has to be self contained.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Even rocksdb does something similar

Copy link
Contributor

Choose a reason for hiding this comment

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

I disagree with you because if ManagedRawSstFileReader has some dependency on NativeLibrary, it should be injected to it.
Since it is static loading, we can move this code inside the constructor of ManagedRawSstFileReader or static block (which I don't think possible because it is needed to be loaded based on the config) but loading this way doesn't feel good to me.

pom.xml Outdated Show resolved Hide resolved
Copy link
Contributor

@hemantk-12 hemantk-12 left a comment

Choose a reason for hiding this comment

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

Overall looks good to me.

There are few cosmetics comments which are not addressed. Please create follow up task if you don't intend to fix them as part of this PR.

@swamirishi swamirishi merged commit d883d7d into apache:master Feb 22, 2024
37 checks passed
@swamirishi
Copy link
Contributor Author

Thanks for the review @hemantk-12 and @smengcl

@smengcl
Copy link
Contributor

smengcl commented Feb 22, 2024

Thanks @swamirishi for the fix and improvement.

swamirishi added a commit to swamirishi/ozone that referenced this pull request Jun 10, 2024
…leReaderIterator (apache#6182)

(cherry picked from commit d883d7d)
Change-Id: I5cade05d6be565acc3d93b6376e7ecf679dccf55
xichen01 pushed a commit to xichen01/ozone that referenced this pull request Jul 26, 2024
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.

3 participants