Skip to content

Commit

Permalink
chore: cr
Browse files Browse the repository at this point in the history
  • Loading branch information
DevilExileSu committed Sep 14, 2023
1 parent f323dae commit ee38e98
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/mito2/src/engine/truncate_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

use std::collections::HashMap;
use std::sync::Arc;
use std::time::Duration;

use api::v1::Rows;
use common_recordbatch::RecordBatches;
Expand Down Expand Up @@ -351,5 +350,5 @@ async fn test_engine_truncate_during_flush() {

let region = engine.get_region(region_id).unwrap();
let current_version = region.version_control.current().version;
assert_eq!(current_version.truncated_entry_id, None);
assert_eq!(current_version.truncated_entry_id, Some(entry_id));
}
6 changes: 6 additions & 0 deletions src/mito2/src/manifest/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ pub struct RegionManifest {
pub flushed_sequence: SequenceNumber,
/// Current manifest version.
pub manifest_version: ManifestVersion,
/// Last WAL entry id of truncated data.
pub truncated_entry_id: Option<EntryId>,
}

#[derive(Debug, Default)]
Expand All @@ -88,6 +90,7 @@ pub struct RegionManifestBuilder {
flushed_entry_id: EntryId,
flushed_sequence: SequenceNumber,
manifest_version: ManifestVersion,
truncated_entry_id: Option<EntryId>,
}

impl RegionManifestBuilder {
Expand All @@ -100,6 +103,7 @@ impl RegionManifestBuilder {
flushed_entry_id: s.flushed_entry_id,
manifest_version: s.manifest_version,
flushed_sequence: s.flushed_sequence,
truncated_entry_id: s.truncated_entry_id,
}
} else {
Default::default()
Expand Down Expand Up @@ -131,6 +135,7 @@ impl RegionManifestBuilder {
self.manifest_version = manifest_version;
self.flushed_entry_id = truncate.truncated_entry_id;
self.flushed_sequence = truncate.truncated_sequence;
self.truncated_entry_id = Some(truncate.truncated_entry_id);
self.files.clear();
}

Expand All @@ -147,6 +152,7 @@ impl RegionManifestBuilder {
flushed_entry_id: self.flushed_entry_id,
flushed_sequence: self.flushed_sequence,
manifest_version: self.manifest_version,
truncated_entry_id: self.truncated_entry_id,
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/mito2/src/manifest/tests/checkpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ async fn manager_with_checkpoint_distance_1() {
.await
.unwrap();
let raw_json = std::str::from_utf8(&raw_bytes).unwrap();
let expected_json = "{\"size\":790,\"version\":9,\"checksum\":null,\"extend_metadata\":{}}";
let expected_json = "{\"size\":816,\"version\":9,\"checksum\":null,\"extend_metadata\":{}}";
assert_eq!(expected_json, raw_json);

// reopen the manager
Expand Down
1 change: 1 addition & 0 deletions src/mito2/src/region/opener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ impl RegionOpener {
.add_files(file_purger.clone(), manifest.files.values().cloned())
.flushed_entry_id(manifest.flushed_entry_id)
.flushed_sequence(manifest.flushed_sequence)
.truncated_entry_id(manifest.truncated_entry_id)
.build();
let flushed_entry_id = version.flushed_entry_id;
let version_control = Arc::new(VersionControl::new(version));
Expand Down
5 changes: 4 additions & 1 deletion src/mito2/src/worker/handle_truncate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ impl<S: LogStore> RegionWorkerLoop<S> {

// Make all data obsolete.
self.wal.obsolete(region_id, truncated_entry_id).await?;
info!("Done truncate");
info!(
"Complete truncate region: {}, entry id: {} and sequence: {} are truncated",
region_id, truncated_entry_id, truncated_sequence
);

Ok(Output::AffectedRows(0))
}
Expand Down

0 comments on commit ee38e98

Please sign in to comment.