-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
rocksdbjni: Transaction#multiGetForUpdate returns null for large key counts #9006
Labels
Comments
DaMatrix
added a commit
to PorkStudios/FarPlaneTwo
that referenced
this issue
Oct 27, 2021
alanpaxton
added a commit
to alanpaxton/rocksdb
that referenced
this issue
Oct 17, 2022
@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.
facebook-github-bot
pushed a commit
that referenced
this issue
Oct 27, 2022
…nsureLocalCapacity() calls (#10674) Summary: 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. Pull Request resolved: #10674 Reviewed By: ajkr Differential Revision: D40515361 Pulled By: jay-zhuang fbshipit-source-id: f1be0126181a698b3ad27c0945a39c54d950aa25
Hi @DaMatrix just reviewing PRs/issues, this should all be resolved, working and regression tested. Could you close ? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected behavior
Transaction#multiGetForUpdate
should never returnnull
.Actual behavior
Transaction#multiGetForUpdate
(the version which accepts aList<ColumnFamilyHandle>
) returnsnull
when called with a large number of keys (>= 65537 keys, according to my test code).Upon further investigation, this seems to affect other methods as well: the standard
RocksDB#multiGetAsList(List<byte[]>)
throws aNullPointerException
when called with >= 65537 keys.Steps to reproduce the behavior
Here's a minimum reproducible example
If I'm not mistaken, the root cause is in from the following code:
rocksdb/java/rocksjni/transaction.cc
Lines 253 to 257 in 2e09a54
To the best of my knowledge,
EnsureLocalCapacity
is for ensuring that the requested number of local object references can be held by the current stack frame. It therefore makes very little sense to check it with the length of a primitive array (long[]
in this case).Here are all the instances I could find of
EnsureLocalCapacity
being used with the length of a primitive array:rocksdb/java/rocksjni/optimistic_transaction_db.cc
Line 90 in 2e09a54
rocksdb/java/rocksjni/transaction_db.cc
Line 101 in 2e09a54
rocksdb/java/rocksjni/transaction.cc
Line 253 in 2e09a54
rocksdb/java/rocksjni/transaction.cc
Line 316 in 2e09a54
rocksdb/java/rocksjni/transaction.cc
Line 669 in 2e09a54
rocksdb/java/rocksjni/transaction.cc
Line 688 in 2e09a54
rocksdb/java/rocksjni/transaction.cc
Line 901 in 2e09a54
I'm pretty sure these are also wrong (they're not referencing primitive arrays, but object arrays whose references seem to be safely cleaned up - one of them is even commented regarding the same issue!):
rocksdb/java/rocksjni/optimistic_transaction_db.cc
Line 66 in 2e09a54
rocksdb/java/rocksjni/transaction_db.cc
Line 69 in 2e09a54
rocksdb/java/rocksjni/transaction.cc
Line 300 in 2e09a54
rocksdb/java/rocksjni/rocksjni.cc
Line 1718 in 2e09a54
rocksdb/java/rocksjni/rocksjni.cc
Lines 1792 to 1794 in 2e09a54
The text was updated successfully, but these errors were encountered: