Skip to content

Commit

Permalink
refactor: skip checking the existence of the SST files (#4602)
Browse files Browse the repository at this point in the history
refactor: skip checking the existence of the SST files when region is directly edited
  • Loading branch information
MichaelScofield authored Aug 22, 2024
1 parent d628079 commit 470208d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
8 changes: 0 additions & 8 deletions src/mito2/src/access_layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,6 @@ impl AccessLayer {

Ok(sst_info)
}
/// Returns whether the file exists in the object store.
pub(crate) async fn is_exist(&self, file_meta: &FileMeta) -> Result<bool> {
let path = location::sst_file_path(&self.region_dir, file_meta.file_id);
self.object_store
.is_exist(&path)
.await
.context(OpenDalSnafu)
}
}

/// `OperationType` represents the origin of the `SstWriteRequest`.
Expand Down
17 changes: 1 addition & 16 deletions src/mito2/src/worker/handle_manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
use std::collections::{HashMap, VecDeque};

use common_telemetry::{info, warn};
use snafu::ensure;
use store_api::storage::RegionId;

use crate::error::{InvalidRequestSnafu, RegionBusySnafu, RegionNotFoundSnafu, Result};
use crate::error::{RegionBusySnafu, RegionNotFoundSnafu, Result};
use crate::manifest::action::{
RegionChange, RegionEdit, RegionMetaAction, RegionMetaActionList, RegionTruncate,
};
Expand Down Expand Up @@ -289,20 +288,6 @@ impl<S> RegionWorkerLoop<S> {
/// Checks the edit, writes and applies it.
async fn edit_region(region: &MitoRegionRef, edit: RegionEdit) -> Result<()> {
let region_id = region.region_id;
for file_meta in &edit.files_to_add {
let is_exist = region.access_layer.is_exist(file_meta).await?;
ensure!(
is_exist,
InvalidRequestSnafu {
region_id,
reason: format!(
"trying to add a not exist file '{}' when editing region",
file_meta.file_id
)
}
);
}

info!("Applying {edit:?} to region {}", region_id);

let action_list = RegionMetaActionList::with_action(RegionMetaAction::Edit(edit));
Expand Down

0 comments on commit 470208d

Please sign in to comment.