Fix CompactRange incorrect buffer release

Summary:
While running `make jtest` using IBM Java, it fails at compactRangeToLevel with the below error.

```
Run: org.rocksdb.RocksDBTest testing now -> compactRangeToLevel
JVMJNCK056E JNI error in ReleaseByteArrayElements: Got memory 0x00003FFF94AA8908 from object 0x00000000000C7F78, releasing from 0x00000000000C7F68
JVMJNCK077E Error detected in org/rocksdb/RocksDB.compactRange0(J[BI[BIZII)V

JVMJNCK024E JNI error detected. Aborting.
JVMJNCK025I Use -Xcheck:jni:nonfatal to continue running when errors are detected.

Fatal error: JNI error
Makefile:205: recipe for target 'run_test' failed
make[1]: *** [run_test] Error 87
make[1]: Leaving directory '/home/ubuntu/rocksdb/java'
Makefile:1542: recipe for target 'jtest' failed
make: *** [jtest] Error 2
```

After checking the code, it is vivid that we are messing up the `ReleaseByteArrayElements` args in `rocksdb_compactrange_helper`.

```
   .................
   1959     s = db->CompactRange(compact_options, &begin_slice, &end_slice);
   1960   }
Closes https://github.com/facebook/rocksdb/pull/2060

Differential Revision: D4831427

Pulled By: yiwu-arbug

fbshipit-source-id: dd02037
This commit is contained in:
Ayappan 2017-04-06 13:59:24 -07:00 committed by Facebook Github Bot
parent df6f5a3772
commit 1d068f6067

View file

@ -1959,8 +1959,8 @@ bool rocksdb_compactrange_helper(JNIEnv* env, rocksdb::DB* db,
s = db->CompactRange(compact_options, &begin_slice, &end_slice);
}
env->ReleaseByteArrayElements(jend, begin, JNI_ABORT);
env->ReleaseByteArrayElements(jbegin, end, JNI_ABORT);
env->ReleaseByteArrayElements(jend, end, JNI_ABORT);
env->ReleaseByteArrayElements(jbegin, begin, JNI_ABORT);
if (s.ok()) {
return true;