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

RocksJava API - fix Transaction.multiGet() size limit, remove bogus EnsureLocalCapacity() calls #10674

Conversation

alanpaxton
Copy link
Contributor

@alanpaxton alanpaxton commented Sep 14, 2022

Resolves @see #9006

Fixes 2 related issues with JNI local references in the RocksJava API.

  1. Some instances of RocksJava API JNI code appear to have misunderstood the reason for JNIEnv->EnsureLocalCapacity() and are carrying out bogus checks which happen to fail with some larger parameter values (many column families in a single call, very long key names or values). Remove these checks and add some regression tests for the previous failures.

  2. The helper for Transaction multiGet operations (multiGet(), multiGetForUpdate(),...) is limited in the number of keys it can get() for because it requires a corresponding number of live local references. Refactor the helper slightly, copying out the key contents within a loop so that the references don't have to exist at the same time.

@alanpaxton alanpaxton force-pushed the fb-9006-transaction-multiget-large-keys branch from 897a791 to e522825 Compare September 14, 2022 11:30
@alanpaxton alanpaxton marked this pull request as draft September 14, 2022 13:28
@alanpaxton alanpaxton force-pushed the fb-9006-transaction-multiget-large-keys branch from e522825 to e7fe8af Compare September 20, 2022 15:04
@alanpaxton alanpaxton changed the title Remove bogus EnsureLocalCapacity Fix Transaction.multiGet() size limit, Remove bogus EnsureLocalCapacity Sep 21, 2022
@alanpaxton alanpaxton force-pushed the fb-9006-transaction-multiget-large-keys branch from b0adb4a to 675ec7c Compare September 21, 2022 13:55
@alanpaxton alanpaxton changed the title Fix Transaction.multiGet() size limit, Remove bogus EnsureLocalCapacity RocksJava API - fix Transaction.multiGet() size limit, remove bogus EnsureLocalCapacity() calls Sep 21, 2022
@alanpaxton alanpaxton marked this pull request as ready for review September 21, 2022 15:20
@see facebook#9006

Instances of RocksJava API JNI code appear to have misunderstood the reason for JNIEnv->EnsureLocalCapacity() and are carrying out bogus checks which happen to fail with some larger parameter values (many column familes in a single call, very long key names or values). Remove these checks and add some regression tests for the previous failures.

Add/update tests to ensure that methods with EnsureLocalCapacity() removed still work; testing was perhaps a bit thin in places.
In conceptually similar (though not identical, APIs are a bit mismatched) way to standard multiGet, keys are now copied into jbyte[] so that local object references need only be held one at a time inside a loop.
Tests are systematic, write values to 10% of keys, handle duplicate keys (byte[] equality needs wrapped for proper value equals()).
@alanpaxton alanpaxton force-pushed the fb-9006-transaction-multiget-large-keys branch from 675ec7c to caf62e9 Compare October 17, 2022 15:09
@facebook-github-bot
Copy link
Contributor

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

Copy link
Contributor

@jay-zhuang jay-zhuang left a comment

Choose a reason for hiding this comment

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

LGTM

@facebook-github-bot
Copy link
Contributor

@alanpaxton has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@jay-zhuang 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