Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: limit input sst size when compact for old bucket #910

Merged
merged 2 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions analytic_engine/src/compaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

//! Compaction.

use std::{collections::HashMap, str::FromStr, sync::Arc};
use std::{collections::HashMap, fmt, str::FromStr, sync::Arc};

use common_util::config::{ReadableSize, TimeUnit};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -316,7 +316,7 @@ pub struct ExpiredFiles {
pub files: Vec<FileHandle>,
}

#[derive(Debug, Default, Clone)]
#[derive(Default, Clone)]
pub struct CompactionTask {
pub compaction_inputs: Vec<CompactionInputFiles>,
pub expired: Vec<ExpiredFiles>,
Expand Down Expand Up @@ -352,6 +352,30 @@ impl CompactionTask {
}
}

impl fmt::Debug for CompactionTask {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("CompactionTask")
.field("inputs", &self.compaction_inputs)
.field(
"expired",
&self
.expired
.iter()
.map(|expired| {
format!(
"level:{}, files:{:?}",
expired.level,
expired.files.iter().map(|f| f.id())
)
})
// only print first 10 files
.take(10)
.collect::<Vec<_>>(),
)
.finish()
}
}

pub struct PickerManager {
default_picker: CompactionPickerRef,
time_window_picker: CompactionPickerRef,
Expand Down
7 changes: 4 additions & 3 deletions analytic_engine/src/compaction/picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ impl TimeWindowPicker {

let all_keys: BTreeSet<_> = buckets.keys().collect();

// First compact latest buckets
for key in all_keys.into_iter().rev() {
if let Some(bucket) = buckets.get(key) {
debug!("Key {}, now {}", key, now);
Expand Down Expand Up @@ -577,7 +578,7 @@ impl LevelPicker for TimeWindowPicker {

debug!("TWCS compaction options: {:?}", opts);

let (buckets, ts) = Self::get_buckets(
let (buckets, max_bucket_ts) = Self::get_buckets(
&uncompact_files,
&ctx.segment_duration,
opts.timestamp_resolution,
Expand All @@ -589,8 +590,8 @@ impl LevelPicker for TimeWindowPicker {
&ctx.segment_duration,
opts.timestamp_resolution,
);
debug!("now {}, max_ts: {}", now, ts);
assert!(now >= ts);
debug!("now {}, max_ts: {}", now, max_bucket_ts);
Rachelint marked this conversation as resolved.
Show resolved Hide resolved
assert!(now >= max_bucket_ts);

Self::newest_bucket(buckets, opts.size_tiered, now)
}
Expand Down
2 changes: 1 addition & 1 deletion analytic_engine/src/instance/flush_compaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ impl SpaceStore {
}

info!(
"try do compaction for table:{}#{}, estimated input files size:{}, input files number:{}",
"Try do compaction for table:{}#{}, estimated input files size:{}, input files number:{}",
table_data.name,
table_data.id,
task.estimated_total_input_file_size(),
Expand Down
1 change: 0 additions & 1 deletion analytic_engine/src/sst/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ impl fmt::Debug for FileHandle {
f.debug_struct("FileHandle")
.field("meta", &self.inner.meta)
.field("being_compacted", &self.being_compacted())
.field("metrics", &self.inner.metrics)
.finish()
}
}
Expand Down