Skip to content

Commit 14e0e4c

Browse files
authored
refactor: do not upsert copied-files set if both purge and force are enabled (#10855)
* do not upset copied-files set if both purge and force are enalbed * adjust logging * adjust logging message
1 parent aa1cd91 commit 14e0e4c

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

src/query/service/src/catalogs/default/mutable_catalog.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,14 @@ impl Catalog for MutableCatalog {
287287
req: UpdateTableMetaReq,
288288
) -> Result<UpdateTableMetaReply> {
289289
match table_info.db_type.clone() {
290-
DatabaseType::NormalDB => Ok(self.ctx.meta.update_table_meta(req).await?),
290+
DatabaseType::NormalDB => {
291+
info!(
292+
"updating table meta. table desc: [{}], has copied files: [{}]?",
293+
table_info.desc,
294+
req.copied_files.is_some()
295+
);
296+
Ok(self.ctx.meta.update_table_meta(req).await?)
297+
}
291298
DatabaseType::ShareDB(share_ident) => {
292299
let db = self
293300
.get_database(&share_ident.tenant, &share_ident.share_name)

src/query/service/src/interpreters/interpreter_copy.rs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,10 @@ impl CopyInterpreter {
260260
info!("end to list files: got {} files", num_all_files);
261261

262262
let need_copy_file_infos = if force {
263+
info!(
264+
"force mode, ignore file filtering. ({}.{})",
265+
database_name, table_name
266+
);
263267
all_source_file_infos
264268
} else {
265269
// Status.
@@ -429,13 +433,22 @@ impl CopyInterpreter {
429433
let table_id = to_table.get_id();
430434
let expire_hours = ctx.get_settings().get_load_file_metadata_expire_hours()?;
431435

432-
let fail_if_duplicated = !force;
433-
let upsert_copied_files_request = Self::upsert_copied_files_request(
434-
table_id,
435-
expire_hours,
436-
copied_file_tree,
437-
fail_if_duplicated,
438-
);
436+
let upsert_copied_files_request = {
437+
if stage_info.copy_options.purge && force {
438+
// if `purge-after-copy` is enabled, and in `force` copy mode,
439+
// we do not need to upsert copied files into meta server
440+
info!("[purge] and [force] are both enabled, will not update copied-files set. ({})", &to_table.get_table_info().desc);
441+
None
442+
} else {
443+
let fail_if_duplicated = !force;
444+
Self::upsert_copied_files_request(
445+
table_id,
446+
expire_hours,
447+
copied_file_tree,
448+
fail_if_duplicated,
449+
)
450+
}
451+
};
439452

440453
{
441454
let status = format!("begin commit, number of copied files:{}", num_copied_files);

0 commit comments

Comments
 (0)