Skip to content

Commit

Permalink
This is an automated cherry-pick of tikv#15359
Browse files Browse the repository at this point in the history
close tikv#15355

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
LykxSassinator authored and ti-chi-bot committed Aug 18, 2023
1 parent f883d4e commit 3511e30
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 13 deletions.
12 changes: 6 additions & 6 deletions etc/config-template.toml
Original file line number Diff line number Diff line change
Expand Up @@ -860,16 +860,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
20 changes: 13 additions & 7 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,17 @@ macro_rules! cf_config {
#[online_config(skip)]
pub checksum: ChecksumType,
#[online_config(skip)]
<<<<<<< HEAD
pub max_compactions: u32,
// `ttl == None` means using default setting in Rocksdb.
=======
pub max_compactions: Option<u32>,
// `ttl == None` means disable this feature in Rocksdb.
>>>>>>> cb6531fa57 (compaction: disable periodic-compaction and ttl as default. (#15359))
// `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 @@ -635,12 +640,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
24 changes: 24 additions & 0 deletions tests/integrations/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,15 @@ fn test_serde_custom_tikv_config() {
prepopulate_block_cache: PrepopulateBlockCache::FlushOnly,
format_version: 5,
checksum: ChecksumType::XXH3,
<<<<<<< HEAD
max_compactions: 3,
ttl: None,
periodic_compaction_seconds: None,
=======
max_compactions: Some(3),
ttl: Some(ReadableDuration::days(10)),
periodic_compaction_seconds: Some(ReadableDuration::days(10)),
>>>>>>> cb6531fa57 (compaction: disable periodic-compaction and ttl as default. (#15359))
},
writecf: WriteCfConfig {
block_size: ReadableSize::kb(12),
Expand Down Expand Up @@ -448,9 +454,15 @@ fn test_serde_custom_tikv_config() {
prepopulate_block_cache: PrepopulateBlockCache::FlushOnly,
format_version: 5,
checksum: ChecksumType::XXH3,
<<<<<<< HEAD
max_compactions: 3,
ttl: None,
periodic_compaction_seconds: None,
=======
max_compactions: Some(3),
ttl: Some(ReadableDuration::days(10)),
periodic_compaction_seconds: Some(ReadableDuration::days(10)),
>>>>>>> cb6531fa57 (compaction: disable periodic-compaction and ttl as default. (#15359))
},
lockcf: LockCfConfig {
block_size: ReadableSize::kb(12),
Expand Down Expand Up @@ -519,9 +531,15 @@ fn test_serde_custom_tikv_config() {
prepopulate_block_cache: PrepopulateBlockCache::FlushOnly,
format_version: 5,
checksum: ChecksumType::XXH3,
<<<<<<< HEAD
max_compactions: 3,
ttl: None,
periodic_compaction_seconds: None,
=======
max_compactions: Some(3),
ttl: Some(ReadableDuration::days(10)),
periodic_compaction_seconds: Some(ReadableDuration::days(10)),
>>>>>>> cb6531fa57 (compaction: disable periodic-compaction and ttl as default. (#15359))
},
raftcf: RaftCfConfig {
block_size: ReadableSize::kb(12),
Expand Down Expand Up @@ -590,9 +608,15 @@ fn test_serde_custom_tikv_config() {
prepopulate_block_cache: PrepopulateBlockCache::FlushOnly,
format_version: 5,
checksum: ChecksumType::XXH3,
<<<<<<< HEAD
max_compactions: 3,
ttl: None,
periodic_compaction_seconds: None,
=======
max_compactions: Some(3),
ttl: Some(ReadableDuration::days(10)),
periodic_compaction_seconds: Some(ReadableDuration::days(10)),
>>>>>>> cb6531fa57 (compaction: disable periodic-compaction and ttl as default. (#15359))
},
titan: titan_db_config.clone(),
};
Expand Down
8 changes: 8 additions & 0 deletions tests/integrations/config/test-custom.toml
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ prepopulate-block-cache = "flush-only"
format-version = 5
checksum = "xxh3"
max-compactions = 3
ttl = "10d"
periodic-compaction-seconds = "10d"

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

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

[rocksdb.raftcf]
block-size = "12KB"
Expand Down Expand Up @@ -499,6 +505,8 @@ prepopulate-block-cache = "flush-only"
format-version = 5
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 3511e30

Please sign in to comment.