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

Support flush reasons above 12 in Java integration #13246

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rpuch
Copy link
Contributor

@rpuch rpuch commented Dec 25, 2024

Summary:

FlushReason enum in C++ has members up to 15, but in Java, the mirroring FlushReason only supports reason codes up to 12. This causes exceptions when adding a flush listener.

@rpuch
Copy link
Contributor Author

rpuch commented Dec 25, 2024

Here is what can be seen on the console (probably, it's stderr) during flushes:

java.lang.IllegalArgumentException: Illegal value provided for FlushReason: 13
        at org.rocksdb.FlushReason.fromValue(FlushReason.java:51)
        at org.rocksdb.FlushJobInfo.<init>(FlushJobInfo.java:41)

@alanpaxton
Copy link
Contributor

Hi @rpuch - that looks good. How hard would it be to add a unit test which will fail again if another value is added to the enum in future ?

I'm sure you are aware that you will need to rebase before the RocksDB Core Team will look at merging your change.

@rpuch
Copy link
Contributor Author

rpuch commented Jan 13, 2025

Hi @rpuch - that looks good. How hard would it be to add a unit test which will fail again if another value is added to the enum in future ?

I'm sure you are aware that you will need to rebase before the RocksDB Core Team will look at merging your change.

Hi Alan, thanks for your review. I will try to add such a test, but right now I'm not even sure how to start. Should the test be in Java? If yes, what is the recommended way to obtain max FlushReason value defined in C++? If not in Java, do you have other suggestions?

As for rebasing: sure, I'll do it. But does this rule mean that after any commit gets merged to main, my PR will immediately become stale and will need to be rebased again? Is there a procedure to avoid a potentially long chain of rebases while chasing the fresh main?

@alanpaxton
Copy link
Contributor

Hi @rpuch - I'm not sure if a unit test needs to know the maximum. Just something that calls fromValue() in the way your code does, will fail when it finally sees a new, larger value ?

Let's leave the rebase until we are happy with your PR, then do it once, and you will probably be asked to do it once more by the RocksDB Core Team when they are ready to pull it into their system.

@rpuch
Copy link
Contributor Author

rpuch commented Jan 14, 2025

Hi @rpuch - I'm not sure if a unit test needs to know the maximum. Just something that calls fromValue() in the way your code does, will fail when it finally sees a new, larger value ?

Let's leave the rebase until we are happy with your PR, then do it once, and you will probably be asked to do it once more by the RocksDB Core Team when they are ready to pull it into their system.

The thing is that it's not my code that calls fromValue(). RocksDB Java integration does this itself, see https://github.com/facebook/rocksdb/blob/main/java/src/main/java/org/rocksdb/FlushJobInfo.java#L41

This is the problem I'm trying to fix. I could write a unit test making sure that FlushJobInfo could be instantiated with reason codes up to 15, but this will not help if a new code is added in the C++ part, but gets forgotten in the Java part.

@alanpaxton
Copy link
Contributor

Hi @rpuch - I'm not sure if a unit test needs to know the maximum. Just something that calls fromValue() in the way your code does, will fail when it finally sees a new, larger value ?
Let's leave the rebase until we are happy with your PR, then do it once, and you will probably be asked to do it once more by the RocksDB Core Team when they are ready to pull it into their system.

The thing is that it's not my code that calls fromValue(). RocksDB Java integration does this itself, see https://github.com/facebook/rocksdb/blob/main/java/src/main/java/org/rocksdb/FlushJobInfo.java#L41

This is the problem I'm trying to fix. I could write a unit test making sure that FlushJobInfo could be instantiated with reason codes up to 15, but this will not help if a new code is added in the C++ part, but gets forgotten in the Java part.

Ah sorry, I misunderstood. Then perhaps the best thing is simply to add a comment to the C++ enum, indicating that any new values should be added to Java also.

Summary:

FlushReason enum in C++ has members up to 15, but in Java, the mirroring FlushReason only supports reason codes up to 12. This causes exceptions when adding a flush listener.
@rpuch rpuch force-pushed the support_flush_reasons_above_12_in_java branch from 5f100c7 to 615e0ff Compare January 15, 2025 07:40
@alanpaxton
Copy link
Contributor

Thanks @rpuch that all looks good to me. @jaykorean could you or someone else on the team import this one ?

@facebook-github-bot
Copy link
Contributor

@jaykorean has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

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

Successfully merging this pull request may close these issues.

3 participants