Skip to content

Commit

Permalink
change rocksDB config level_compaction_dynamic_level_bytes to CFOptio…
Browse files Browse the repository at this point in the history
…ns (apache#3860)

### Motivation
After PR apache#3056 , Bookkeeper set `level_compaction_dynamic_level_bytes=true` as `TableOptions` in `entry_location_rocksdb.conf.default` , which will cause `level_compaction_dynamic_level_bytes` lose efficacy and will cause rocksDB .sst file compact sort chaos when update bookie release.
As RocksDB  conf, `level_compaction_dynamic_level_bytes` need set as `CFOptions` https://github.com/facebook/rocksdb/blob/master/examples/rocksdb_option_file_example.ini

<img width="703" alt="image" src="https://user-images.githubusercontent.com/84127069/224640399-d5481fe5-7b75-4229-ac06-3d280aa9ae6d.png">


<img width="240" alt="image" src="https://user-images.githubusercontent.com/84127069/224640621-737d0a42-4e01-4f38-bd5a-862a93bc4b32.png">

### Changes

1. Change `level_compaction_dynamic_level_bytes=true` from `TableOptions` to `CFOptions`  in `entry_location_rocksdb.conf.default` ;
  • Loading branch information
Nicklee007 authored and Anup Ghatage committed Jul 12, 2024
1 parent d7455f8 commit 7c95a4d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public void testRocksDBInitiateWithBookieConfiguration() throws Exception {
assertEquals(64 * 1024 * 1024, options.writeBufferSize());
assertEquals(4, options.maxWriteBufferNumber());
assertEquals(256 * 1024 * 1024, options.maxBytesForLevelBase());
assertEquals(true, options.levelCompactionDynamicLevelBytes());
rocksDB.close();
}

Expand All @@ -78,6 +79,7 @@ public void testRocksDBInitiateWithConfigurationFile() throws Exception {
assertEquals(CompressionType.LZ4_COMPRESSION, familyOptions.compressionType());
assertEquals(1024, familyOptions.writeBufferSize());
assertEquals(1, familyOptions.maxWriteBufferNumber());
assertEquals(true, familyOptions.levelCompactionDynamicLevelBytes());
rocksDB.close();
}

Expand Down Expand Up @@ -113,4 +115,20 @@ public void testReadChecksumTypeFromConfigurationFile() throws Exception {
// After the PR: https://github.com/facebook/rocksdb/pull/10826 merge, we can turn on this test.
assertEquals(ChecksumType.kxxHash, ((BlockBasedTableConfig) familyOptions.tableFormatConfig()).checksumType());
}

@Test
public void testLevelCompactionDynamicLevelBytesFromConfigurationFile() throws Exception {
ServerConfiguration configuration = new ServerConfiguration();
URL url = getClass().getClassLoader().getResource("conf/entry_location_rocksdb.conf");
configuration.setEntryLocationRocksdbConf(url.getPath());
File tmpDir = Files.createTempDirectory("bk-kv-rocksdbtest-file").toFile();
Files.createDirectory(Paths.get(tmpDir.toString(), "subDir"));
KeyValueStorageRocksDB rocksDB = new KeyValueStorageRocksDB(tmpDir.toString(), "subDir",
KeyValueStorageFactory.DbConfigType.EntryLocation, configuration);
assertNotNull(rocksDB.getColumnFamilyDescriptors());

List<ColumnFamilyDescriptor> columnFamilyDescriptorList = rocksDB.getColumnFamilyDescriptors();
ColumnFamilyOptions familyOptions = columnFamilyDescriptorList.get(0).getOptions();
assertEquals(true, familyOptions.levelCompactionDynamicLevelBytes());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
max_bytes_for_level_base=268435456
# set by jni: options.setTargetFileSizeBase
target_file_size_base=67108864
# set by jni: options.setLevelCompactionDynamicLevelBytes
level_compaction_dynamic_level_bytes=true

[TableOptions/BlockBasedTable "default"]
# set by jni: tableOptions.setBlockSize
Expand All @@ -64,6 +66,4 @@
# set by jni: tableOptions.setFilterPolicy, bloomfilter:[bits_per_key]:[use_block_based_builder]
filter_policy=rocksdb.BloomFilter:10:false
# set by jni: tableOptions.setCacheIndexAndFilterBlocks
cache_index_and_filter_blocks=true
# set by jni: options.setLevelCompactionDynamicLevelBytes
level_compaction_dynamic_level_bytes=true
cache_index_and_filter_blocks=true
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
write_buffer_size=1024
# set by jni: options.setMaxWriteBufferNumber
max_write_buffer_number=1
# set by jni: options.setLevelCompactionDynamicLevelBytes
level_compaction_dynamic_level_bytes=true

[TableOptions/BlockBasedTable "default"]
# set by jni: tableOptions.setBlockSize
Expand All @@ -44,6 +46,4 @@
# set by jni: tableOptions.setFilterPolicy, bloomfilter:[bits_per_key]:[use_block_based_builder]
filter_policy=rocksdb.BloomFilter:10:false
# set by jni: tableOptions.setCacheIndexAndFilterBlocks
cache_index_and_filter_blocks=true
# set by jni: options.setLevelCompactionDynamicLevelBytes
level_compaction_dynamic_level_bytes=true
cache_index_and_filter_blocks=true
6 changes: 3 additions & 3 deletions conf/entry_location_rocksdb.conf.default
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
max_bytes_for_level_base=268435456
# set by jni: options.setTargetFileSizeBase
target_file_size_base=67108864
# set by jni: options.setLevelCompactionDynamicLevelBytes
level_compaction_dynamic_level_bytes=true

[TableOptions/BlockBasedTable "default"]
# set by jni: tableOptions.setBlockSize
Expand All @@ -64,6 +66,4 @@
# set by jni: tableOptions.setFilterPolicy, bloomfilter:[bits_per_key]:[use_block_based_builder]
filter_policy=rocksdb.BloomFilter:10:false
# set by jni: tableOptions.setCacheIndexAndFilterBlocks
cache_index_and_filter_blocks=true
# set by jni: options.setLevelCompactionDynamicLevelBytes
level_compaction_dynamic_level_bytes=true
cache_index_and_filter_blocks=true

0 comments on commit 7c95a4d

Please sign in to comment.