diff --git a/src/mito2/src/engine/truncate_test.rs b/src/mito2/src/engine/truncate_test.rs index 83cdfbc279d4..c39f3a0e374b 100644 --- a/src/mito2/src/engine/truncate_test.rs +++ b/src/mito2/src/engine/truncate_test.rs @@ -14,7 +14,6 @@ use std::collections::HashMap; use std::sync::Arc; -use std::time::Duration; use api::v1::Rows; use common_recordbatch::RecordBatches; @@ -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)); } diff --git a/src/mito2/src/manifest/action.rs b/src/mito2/src/manifest/action.rs index 89dfeccf0de6..68899c788771 100644 --- a/src/mito2/src/manifest/action.rs +++ b/src/mito2/src/manifest/action.rs @@ -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, } #[derive(Debug, Default)] @@ -88,6 +90,7 @@ pub struct RegionManifestBuilder { flushed_entry_id: EntryId, flushed_sequence: SequenceNumber, manifest_version: ManifestVersion, + truncated_entry_id: Option, } impl RegionManifestBuilder { @@ -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() @@ -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(); } @@ -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, }) } } diff --git a/src/mito2/src/manifest/tests/checkpoint.rs b/src/mito2/src/manifest/tests/checkpoint.rs index 9dd635b8a73a..e1b1c54cd82c 100644 --- a/src/mito2/src/manifest/tests/checkpoint.rs +++ b/src/mito2/src/manifest/tests/checkpoint.rs @@ -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 diff --git a/src/mito2/src/region/opener.rs b/src/mito2/src/region/opener.rs index 91de9cf4761c..157eff1a4a5d 100644 --- a/src/mito2/src/region/opener.rs +++ b/src/mito2/src/region/opener.rs @@ -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)); diff --git a/src/mito2/src/worker/handle_truncate.rs b/src/mito2/src/worker/handle_truncate.rs index 4ee6dda2cdfe..2afa76fd754b 100644 --- a/src/mito2/src/worker/handle_truncate.rs +++ b/src/mito2/src/worker/handle_truncate.rs @@ -56,7 +56,10 @@ impl RegionWorkerLoop { // 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)) }