Skip to content

Commit

Permalink
feat: support disable RocksDB auto-compaction by configuration (#2586)
Browse files Browse the repository at this point in the history
  • Loading branch information
haohao0103 authored Jul 16, 2024
1 parent 899dc8e commit 5dfcc3f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ public class RocksDBOptions extends OptionHolder {
disallowEmpty(),
"rocksdb-snapshot"
);
public static final ConfigOption<Boolean> DISABLE_AUTO_COMPACTION =
new ConfigOption<>(
"rocksdb.disable_auto_compaction",
"Set disable auto compaction.",
disallowEmpty(),
false
);
public static final ConfigConvOption<String, CompactionStyle> COMPACTION_STYLE =
new ConfigConvOption<>(
"rocksdb.compaction_style",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,9 @@ private void openRocksDB(String dbDataPath, long version) {
List<byte[]> columnFamilyBytes = RocksDB.listColumnFamilies(new Options(), dbPath);

ColumnFamilyOptions cfOptions = new ColumnFamilyOptions();
if (hugeConfig.get(RocksDBOptions.DISABLE_AUTO_COMPACTION)) {
cfOptions.setDisableAutoCompactions(true);
}
RocksDBSession.initOptions(this.hugeConfig, null, null, cfOptions, cfOptions);

if (columnFamilyBytes.size() > 0) {
Expand Down

0 comments on commit 5dfcc3f

Please sign in to comment.