Skip to content

Commit

Permalink
compaction: disable periodic-compaction and ttl as default. (#15359)
Browse files Browse the repository at this point in the history
close #15355

Disable `periodic-compaction` and `ttl` features as default.

Signed-off-by: lucasliang <nkcs_lykx@hotmail.com>
  • Loading branch information
LykxSassinator committed Aug 18, 2023
1 parent b8075bf commit cb6531f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 22 deletions.
12 changes: 6 additions & 6 deletions etc/config-template.toml
Expand Up @@ -888,16 +888,16 @@

## SST files containing updates older than TTL will go through the compaction
## process. This usually happens in a cascading way so that those entries
## will be compacted to bottommost level/file.
## will be compacted to bottommost level/file. Disabled as default.
##
## Default: 30 days.
# ttl = "30d"
## Default: 0s.
# ttl = "0s"

## SST files older than this value will be picked up for compaction, and
## re-written to the same level as they were before.
## re-written to the same level as they were before. Disabled as default.
##
## Default: 30 days.
# periodic-compaction-seconds = "30d"
## Default: 0s.
# periodic-compaction-seconds = "0s"

## Options for "Default" Column Family for `Titan`.
[rocksdb.defaultcf.titan]
Expand Down
17 changes: 9 additions & 8 deletions src/config/mod.rs
Expand Up @@ -366,11 +366,11 @@ macro_rules! cf_config {
pub checksum: ChecksumType,
#[online_config(skip)]
pub max_compactions: Option<u32>,
// `ttl == None` means using default setting in Rocksdb.
// `ttl == None` means disable this feature in Rocksdb.
// `ttl` in Rocksdb is 30 days as default.
#[online_config(skip)]
pub ttl: Option<ReadableDuration>,
// `periodic_compaction_seconds == None` means using default setting in Rocksdb.
// `periodic_compaction_seconds == None` means disabled this feature in Rocksdb.
// `periodic_compaction_seconds` in Rocksdb is 30 days as default.
#[online_config(skip)]
pub periodic_compaction_seconds: Option<ReadableDuration>,
Expand Down Expand Up @@ -654,12 +654,13 @@ macro_rules! build_cf_opt {
if let Some(r) = $compaction_limiter {
cf_opts.set_compaction_thread_limiter(r);
}
if let Some(ttl) = $opt.ttl {
cf_opts.set_ttl(ttl.0.as_secs());
}
if let Some(secs) = $opt.periodic_compaction_seconds {
cf_opts.set_periodic_compaction_seconds(secs.0.as_secs());
}
cf_opts.set_ttl($opt.ttl.unwrap_or(ReadableDuration::secs(0)).0.as_secs());
cf_opts.set_periodic_compaction_seconds(
$opt.periodic_compaction_seconds
.unwrap_or(ReadableDuration::secs(0))
.0
.as_secs(),
);
cf_opts
}};
}
Expand Down
16 changes: 8 additions & 8 deletions tests/integrations/config/mod.rs
Expand Up @@ -386,8 +386,8 @@ fn test_serde_custom_tikv_config() {
format_version: Some(0),
checksum: ChecksumType::XXH3,
max_compactions: Some(3),
ttl: None,
periodic_compaction_seconds: None,
ttl: Some(ReadableDuration::days(10)),
periodic_compaction_seconds: Some(ReadableDuration::days(10)),
},
writecf: WriteCfConfig {
block_size: ReadableSize::kb(12),
Expand Down Expand Up @@ -459,8 +459,8 @@ fn test_serde_custom_tikv_config() {
format_version: Some(0),
checksum: ChecksumType::XXH3,
max_compactions: Some(3),
ttl: None,
periodic_compaction_seconds: None,
ttl: Some(ReadableDuration::days(10)),
periodic_compaction_seconds: Some(ReadableDuration::days(10)),
},
lockcf: LockCfConfig {
block_size: ReadableSize::kb(12),
Expand Down Expand Up @@ -532,8 +532,8 @@ fn test_serde_custom_tikv_config() {
format_version: Some(0),
checksum: ChecksumType::XXH3,
max_compactions: Some(3),
ttl: None,
periodic_compaction_seconds: None,
ttl: Some(ReadableDuration::days(10)),
periodic_compaction_seconds: Some(ReadableDuration::days(10)),
},
raftcf: RaftCfConfig {
block_size: ReadableSize::kb(12),
Expand Down Expand Up @@ -605,8 +605,8 @@ fn test_serde_custom_tikv_config() {
format_version: Some(0),
checksum: ChecksumType::XXH3,
max_compactions: Some(3),
ttl: None,
periodic_compaction_seconds: None,
ttl: Some(ReadableDuration::days(10)),
periodic_compaction_seconds: Some(ReadableDuration::days(10)),
},
titan: titan_db_config.clone(),
};
Expand Down
8 changes: 8 additions & 0 deletions tests/integrations/config/test-custom.toml
Expand Up @@ -341,6 +341,8 @@ prepopulate-block-cache = "flush-only"
format-version = 0
checksum = "xxh3"
max-compactions = 3
ttl = "10d"
periodic-compaction-seconds = "10d"

[rocksdb.defaultcf.titan]
min-blob-size = "2018B"
Expand Down Expand Up @@ -406,6 +408,8 @@ prepopulate-block-cache = "flush-only"
format-version = 0
checksum = "xxh3"
max-compactions = 3
ttl = "10d"
periodic-compaction-seconds = "10d"

[rocksdb.lockcf]
block-size = "12KB"
Expand Down Expand Up @@ -458,6 +462,8 @@ prepopulate-block-cache = "flush-only"
format-version = 0
checksum = "xxh3"
max-compactions = 3
ttl = "10d"
periodic-compaction-seconds = "10d"

[rocksdb.raftcf]
block-size = "12KB"
Expand Down Expand Up @@ -510,6 +516,8 @@ prepopulate-block-cache = "flush-only"
format-version = 0
checksum = "xxh3"
max-compactions = 3
ttl = "10d"
periodic-compaction-seconds = "10d"

[raftdb]
wal-recovery-mode = "skip-any-corrupted-records"
Expand Down

0 comments on commit cb6531f

Please sign in to comment.