diff --git a/src/common/base/src/base/progress.rs b/src/common/base/src/base/progress.rs index 1c70375e25ab5..a125a545d1a38 100644 --- a/src/common/base/src/base/progress.rs +++ b/src/common/base/src/base/progress.rs @@ -44,6 +44,11 @@ impl Progress { .fetch_add(progress_values.bytes, Ordering::Relaxed); } + pub fn set(&self, progress_values: &ProgressValues) { + self.rows.store(progress_values.rows, Ordering::Relaxed); + self.bytes.store(progress_values.bytes, Ordering::Relaxed); + } + pub fn fetch(&self) -> ProgressValues { let rows = self.rows.fetch_min(0, Ordering::SeqCst); let bytes = self.bytes.fetch_min(0, Ordering::SeqCst); diff --git a/src/query/service/src/interpreters/common/compact_hook.rs b/src/query/service/src/interpreters/common/compact_hook.rs index 420f8d3048442..6b478bf78a0e2 100644 --- a/src/query/service/src/interpreters/common/compact_hook.rs +++ b/src/query/service/src/interpreters/common/compact_hook.rs @@ -135,10 +135,15 @@ async fn compact_table( let complete_executor = PipelineCompleteExecutor::from_pipelines(pipelines, settings)?; + // keep the original progress value + let progress_value = ctx.get_write_progress_value(); // Clears previously generated segment locations to avoid duplicate data in the refresh phase ctx.clear_segment_locations()?; ctx.set_executor(complete_executor.get_inner())?; complete_executor.execute()?; + + // reset the progress value + ctx.get_write_progress().set(&progress_value); } Ok(()) } diff --git a/tests/suites/0_stateless/20+_others/20_0015_compact_hook_stas_issue_13947.result b/tests/suites/0_stateless/20+_others/20_0015_compact_hook_stas_issue_13947.result new file mode 100644 index 0000000000000..2c43c9afdad11 --- /dev/null +++ b/tests/suites/0_stateless/20+_others/20_0015_compact_hook_stas_issue_13947.result @@ -0,0 +1,4 @@ +expects .stats.write_progress.rows be 2 +expects .error be null +2 +null diff --git a/tests/suites/0_stateless/20+_others/20_0015_compact_hook_stas_issue_13947.sh b/tests/suites/0_stateless/20+_others/20_0015_compact_hook_stas_issue_13947.sh new file mode 100755 index 0000000000000..0bd510417b0cc --- /dev/null +++ b/tests/suites/0_stateless/20+_others/20_0015_compact_hook_stas_issue_13947.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +. "$CURDIR"/../../../shell_env.sh + +# set up +cat <