update rocksdbjni to v6.29.4 for compatibility with arm64 CPU architecture (#3634)

* update rocksdbjni to v6.29.5 for compatibility with arm64 CPU

Signed-off-by: Pedro Novais <jpvnovais@gmail.com>
Co-authored-by: garyschulte <garyschulte@gmail.com>
pull/3712/head
Pedro Novais 3 years ago committed by GitHub
parent 00851d042c
commit fe673431fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      gradle/versions.gradle
  2. 39
      plugins/rocksdb/src/main/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/RocksDBColumnarKeyValueStorage.java
  3. 34
      plugins/rocksdb/src/test/java/org/hyperledger/besu/plugin/services/storage/rocksdb/unsegmented/RocksDBColumnarKeyValueStorageTest.java
  4. 2
      services/kvstore/src/main/java/org/hyperledger/besu/services/kvstore/SegmentedKeyValueStorage.java
  5. 4
      services/kvstore/src/main/java/org/hyperledger/besu/services/kvstore/SegmentedKeyValueStorageAdapter.java

@ -162,7 +162,7 @@ dependencyManagement {
dependency 'org.openjdk.jmh:jmh-core:1.34' dependency 'org.openjdk.jmh:jmh-core:1.34'
dependency 'org.openjdk.jmh:jmh-generator-annprocess:1.34' dependency 'org.openjdk.jmh:jmh-generator-annprocess:1.34'
dependency 'org.rocksdb:rocksdbjni:6.15.2' dependency 'org.rocksdb:rocksdbjni:6.29.5'
dependency 'org.slf4j:slf4j-api:1.7.25' dependency 'org.slf4j:slf4j-api:1.7.25'

@ -31,6 +31,7 @@ import org.hyperledger.besu.services.kvstore.SegmentedKeyValueStorageTransaction
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
@ -40,7 +41,6 @@ import java.util.function.Predicate;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import com.google.common.collect.ImmutableMap;
import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes;
import org.rocksdb.BlockBasedTableConfig; import org.rocksdb.BlockBasedTableConfig;
import org.rocksdb.ColumnFamilyDescriptor; import org.rocksdb.ColumnFamilyDescriptor;
@ -123,15 +123,14 @@ public class RocksDBColumnarKeyValueStorage
Collectors.toMap( Collectors.toMap(
segment -> Bytes.wrap(segment.getId()), SegmentIdentifier::getName)); segment -> Bytes.wrap(segment.getId()), SegmentIdentifier::getName));
final ImmutableMap.Builder<String, ColumnFamilyHandle> builder = ImmutableMap.builder(); columnHandlesByName = new HashMap<>();
for (ColumnFamilyHandle columnHandle : columnHandles) { for (ColumnFamilyHandle columnHandle : columnHandles) {
final String segmentName = final String segmentName =
requireNonNullElse( requireNonNullElse(
segmentsById.get(Bytes.wrap(columnHandle.getName())), DEFAULT_COLUMN); segmentsById.get(Bytes.wrap(columnHandle.getName())), DEFAULT_COLUMN);
builder.put(segmentName, columnHandle); columnHandlesByName.put(segmentName, columnHandle);
} }
columnHandlesByName = builder.build();
} catch (final RocksDBException e) { } catch (final RocksDBException e) {
throw new StorageException(e); throw new StorageException(e);
} }
@ -195,18 +194,28 @@ public class RocksDBColumnarKeyValueStorage
} }
@Override @Override
public void clear(final ColumnFamilyHandle segmentHandle) { public ColumnFamilyHandle clear(final ColumnFamilyHandle segmentHandle) {
try (final RocksIterator rocksIterator = db.newIterator(segmentHandle)) { try {
rocksIterator.seekToFirst();
if (rocksIterator.isValid()) { var entry =
final byte[] firstKey = rocksIterator.key(); columnHandlesByName.entrySet().stream()
rocksIterator.seekToLast(); .filter(e -> e.getValue().equals(segmentHandle))
if (rocksIterator.isValid()) { .findAny();
final byte[] lastKey = rocksIterator.key();
db.deleteRange(segmentHandle, firstKey, lastKey); if (entry.isPresent()) {
db.delete(segmentHandle, lastKey); String segmentName = entry.get().getKey();
} ColumnFamilyDescriptor descriptor =
new ColumnFamilyDescriptor(
segmentHandle.getName(), segmentHandle.getDescriptor().getOptions());
db.dropColumnFamily(segmentHandle);
segmentHandle.close();
ColumnFamilyHandle newHandle = db.createColumnFamily(descriptor);
columnHandlesByName.put(segmentName, newHandle);
return newHandle;
} }
return segmentHandle;
} catch (final RocksDBException e) { } catch (final RocksDBException e) {
throw new StorageException(e); throw new StorageException(e);
} }

@ -31,6 +31,8 @@ import java.nio.charset.StandardCharsets;
import java.util.Arrays; import java.util.Arrays;
import java.util.Optional; import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Supplier;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
@ -41,6 +43,38 @@ public class RocksDBColumnarKeyValueStorageTest extends AbstractKeyValueStorageT
@Rule public final TemporaryFolder folder = new TemporaryFolder(); @Rule public final TemporaryFolder folder = new TemporaryFolder();
@Test
public void assertClear() throws Exception {
final byte[] key = bytesFromHexString("0001");
final byte[] val1 = bytesFromHexString("0FFF");
final byte[] val2 = bytesFromHexString("1337");
final SegmentedKeyValueStorage<ColumnFamilyHandle> store = createSegmentedStore();
Supplier<ColumnFamilyHandle> segment = () -> store.getSegmentIdentifierByName(TestSegment.FOO);
final Consumer<byte[]> insert =
value -> {
final Transaction<ColumnFamilyHandle> tx = store.startTransaction();
tx.put(segment.get(), key, value);
tx.commit();
};
// insert val:
insert.accept(val1);
final Optional<byte[]> result = store.get(segment.get(), key);
assertThat(result.orElse(null)).isEqualTo(val1);
// clear and assert empty:
store.clear(segment.get());
final Optional<byte[]> truncResult = store.get(segment.get(), key);
assertThat(truncResult).isEmpty();
// insert into empty:
insert.accept(val2);
final Optional<byte[]> nextResult = store.get(segment.get(), key);
assertThat(nextResult.orElse(null)).isEqualTo(val2);
store.close();
}
@Test @Test
public void twoSegmentsAreIndependent() throws Exception { public void twoSegmentsAreIndependent() throws Exception {
final SegmentedKeyValueStorage<ColumnFamilyHandle> store = createSegmentedStore(); final SegmentedKeyValueStorage<ColumnFamilyHandle> store = createSegmentedStore();

@ -74,7 +74,7 @@ public interface SegmentedKeyValueStorage<S> extends Closeable {
Set<byte[]> getAllKeysThat(S segmentHandle, Predicate<byte[]> returnCondition); Set<byte[]> getAllKeysThat(S segmentHandle, Predicate<byte[]> returnCondition);
void clear(S segmentHandle); S clear(S segmentHandle);
/** /**
* Represents a set of changes to be committed atomically. A single transaction is not * Represents a set of changes to be committed atomically. A single transaction is not

@ -26,7 +26,7 @@ import java.util.function.Predicate;
import java.util.stream.Stream; import java.util.stream.Stream;
public class SegmentedKeyValueStorageAdapter<S> implements KeyValueStorage { public class SegmentedKeyValueStorageAdapter<S> implements KeyValueStorage {
private final S segmentHandle; private S segmentHandle;
private final SegmentedKeyValueStorage<S> storage; private final SegmentedKeyValueStorage<S> storage;
public SegmentedKeyValueStorageAdapter( public SegmentedKeyValueStorageAdapter(
@ -37,7 +37,7 @@ public class SegmentedKeyValueStorageAdapter<S> implements KeyValueStorage {
@Override @Override
public void clear() { public void clear() {
storage.clear(segmentHandle); segmentHandle = storage.clear(segmentHandle);
} }
@Override @Override

Loading…
Cancel
Save