fix(mito): unregister drop runtime state before WAL cleanup

The region leaves the region map before its WAL entries are obsoleted. A
failure in `wal.obsolete(...).await?` returned early and skipped
`cleanup_dropped_region_runtime_state`, so the resident compaction, flush,
and index scheduler entries were never unregistered. Since the region is no
longer in the map, a later close cannot clean them up either, leaking the
entries for the rest of the worker's lifetime.

Move the runtime-state cleanup to immediately after the region leaves the
map, before the fallible WAL cleanup. The schedulers only touch their own
state and do not depend on the region map or WAL, so the reordering is safe
and leaves the success path unchanged.

Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
This commit is contained in:
Lei, HUANG
2026-10-10 00:51:57 +08:00
parent bac7a7b1d5
commit 6ff2683f22
+5 -1
View File
@@ -115,6 +115,11 @@ where
// Removes this region from region map to prevent other requests from accessing this region
self.regions.remove_region(region_id);
self.dropping_regions.insert_region(region.clone());
// The region is no longer served once it leaves the map, so unregister its
// runtime state before the fallible WAL cleanup below. Otherwise a WAL
// failure would leak the resident compaction/flush/index entries that only
// this cleanup and close/drop remove.
self.cleanup_dropped_region_runtime_state(region_id).await;
// Delete region data in WAL.
self.wal
@@ -124,7 +129,6 @@ where
&region.provider,
)
.await?;
self.cleanup_dropped_region_runtime_state(region_id).await;
if let Some(store) = &self.series_index_store {
crate::series_index::delete_catalogs(store, region_id).await;