Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove compaction retry when memory limit #739

Merged
merged 21 commits into from
Mar 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 5 additions & 31 deletions analytic_engine/src/compaction/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use snafu::{ResultExt, Snafu};
use table_engine::table::TableId;
use tokio::{
sync::{
mpsc::{self, error::SendError, Receiver, Sender},
mpsc::{self, Receiver, Sender},
Mutex,
},
time,
Expand All @@ -38,9 +38,7 @@ use crate::{
PickerManager, TableCompactionRequest, WaitError, WaiterNotifier,
},
instance::{
flush_compaction::{self, TableFlushOptions},
write_worker::CompactionNotifier,
Instance, SpaceStore,
flush_compaction::TableFlushOptions, write_worker::CompactionNotifier, Instance, SpaceStore,
},
table::data::TableDataRef,
TableOptions,
Expand Down Expand Up @@ -574,12 +572,11 @@ impl ScheduleWorker {
None => {
// Memory usage exceeds the threshold, let's put pack the
// request.
debug!(
"Compaction task is ignored, because of high memory usage:{}, task:{:?}",
warn!(
"Compaction task is ignored, because of high memory usage:{}, task:{:?}, table:{}",
self.memory_limit.usage.load(Ordering::Relaxed),
compaction_task,
compaction_task, table_data.name
);
self.put_back_compaction_request(compact_req).await;
return;
}
};
Expand All @@ -596,29 +593,6 @@ impl ScheduleWorker {
);
}

async fn put_back_compaction_request(&self, req: TableCompactionRequest) {
if let Err(SendError(ScheduleTask::Request(TableCompactionRequest {
compaction_notifier,
waiter,
..
}))) = self.sender.send(ScheduleTask::Request(req)).await
{
let e = Arc::new(
flush_compaction::Other {
msg: "Failed to put back the compaction request for memory usage exceeds",
}
.build(),
);
if let Some(notifier) = compaction_notifier {
notifier.notify_err(e.clone());
}

let waiter_notifier = WaiterNotifier::new(waiter);
let wait_err = WaitError::Compaction { source: e };
waiter_notifier.notify_wait_result(Err(wait_err));
}
}

async fn schedule(&mut self) {
self.compact_tables().await;
self.flush_tables().await;
Expand Down