fix(mito2): hold the bulk compact permit for the whole blocking task (#9252)

Keep the semaphore permit alive throughout queued and running bulk compaction in `src/mito2/src/memtable/bulk.rs`.

(cherry picked from commit e99f75f9b3)

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
This commit is contained in:
dennis zhuang
2026-09-24 18:55:34 +08:00
committed by Lei, HUANG
parent 1cb529510c
commit c66a4aeb37
+5 -1
View File
@@ -1484,11 +1484,15 @@ impl CompactDispatcher {
fn dispatch_compact(&self, task: MemCompactTask) {
let semaphore = self.semaphore.clone();
common_runtime::spawn_global(async move {
let Ok(_permit) = semaphore.acquire().await else {
let Ok(permit) = semaphore.acquire_owned().await else {
return;
};
common_runtime::spawn_blocking_global(move || {
// The async task above returns as soon as the blocking task is
// submitted, so the permit has to travel with it to bound the
// compaction that actually runs.
let _permit = permit;
if let Err(e) = task.compact() {
common_telemetry::error!(e; "Failed to compact memtable, region: {}", task.metadata.region_id);
}