diff --git a/analytic_engine/src/compaction/scheduler.rs b/analytic_engine/src/compaction/scheduler.rs index 07f1c5ccfb..cd8d35dbf2 100644 --- a/analytic_engine/src/compaction/scheduler.rs +++ b/analytic_engine/src/compaction/scheduler.rs @@ -569,9 +569,9 @@ impl ScheduleWorker { async fn handle_table_compaction_request(&self, compact_req: TableCompactionRequest) { let table_data = compact_req.table_data.clone(); - if table_data.is_closed() { + if table_data.allow_compaction() { error!( - "Table is already closed, unable to do compaction further, table:{}, table_id:{}", + "Table status is not ok, unable to compact further, table:{}, table_id:{}", table_data.name, table_data.id ); return; diff --git a/analytic_engine/src/instance/flush_compaction.rs b/analytic_engine/src/instance/flush_compaction.rs index b2eeb1ab09..030b64c335 100644 --- a/analytic_engine/src/instance/flush_compaction.rs +++ b/analytic_engine/src/instance/flush_compaction.rs @@ -725,10 +725,10 @@ impl SpaceStore { .await?; } - if table_data.is_closed() { + if table_data.allow_compaction() { return Other { msg: format!( - "Table is already closed, unable to do update manifest, table:{}, table_id:{}", + "Table status is not ok, unable to update manifest, table:{}, table_id:{}", table_data.name, table_data.id ), } diff --git a/analytic_engine/src/table/data.rs b/analytic_engine/src/table/data.rs index 0d01c94d3d..e2407e83cb 100644 --- a/analytic_engine/src/table/data.rs +++ b/analytic_engine/src/table/data.rs @@ -125,9 +125,8 @@ mod hack { #[derive(PartialEq)] pub enum TableStatus { Ok = 0, - /// No background jobs are allowed if the table is closed. Closed, - /// No write/alter are allowed if the table is dropped. + /// No write/alter are allowed after table is dropped. Dropped, } } @@ -417,8 +416,12 @@ impl TableData { self.status.store(TableStatus::Closed, Ordering::SeqCst) } - pub fn is_closed(&self) -> bool { - self.status.load(Ordering::SeqCst) == TableStatus::Closed + #[inline] + pub fn allow_compaction(&self) -> bool { + match self.status.load(Ordering::SeqCst) { + TableStatus::Ok => true, + TableStatus::Closed | TableStatus::Dropped => false, + } } /// Returns total memtable memory usage in bytes.