Skip to content

Commit

Permalink
add allow compact
Browse files Browse the repository at this point in the history
  • Loading branch information
jiacai2050 committed Sep 14, 2023
1 parent 0b193c5 commit df15292
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions analytic_engine/src/compaction/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions analytic_engine/src/instance/flush_compaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
),
}
Expand Down
11 changes: 7 additions & 4 deletions analytic_engine/src/table/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit df15292

Please sign in to comment.