diff --git a/pageserver/src/http/routes.rs b/pageserver/src/http/routes.rs
index e04f1460a8..b3981b4a8e 100644
--- a/pageserver/src/http/routes.rs
+++ b/pageserver/src/http/routes.rs
@@ -87,7 +87,7 @@ use crate::tenant::timeline::offload::offload_timeline;
use crate::tenant::timeline::offload::OffloadError;
use crate::tenant::timeline::CompactFlags;
use crate::tenant::timeline::CompactOptions;
-use crate::tenant::timeline::CompactRange;
+use crate::tenant::timeline::CompactRequest;
use crate::tenant::timeline::CompactionError;
use crate::tenant::timeline::Timeline;
use crate::tenant::GetTimelineError;
@@ -1978,6 +1978,26 @@ async fn timeline_gc_handler(
json_response(StatusCode::OK, gc_result)
}
+// Cancel scheduled compaction tasks
+async fn timeline_cancel_compact_handler(
+ request: Request
,
+ _cancel: CancellationToken,
+) -> Result, ApiError> {
+ let tenant_shard_id: TenantShardId = parse_request_param(&request, "tenant_shard_id")?;
+ let timeline_id: TimelineId = parse_request_param(&request, "timeline_id")?;
+ check_permission(&request, Some(tenant_shard_id.tenant_id))?;
+ let state = get_state(&request);
+ async {
+ let tenant = state
+ .tenant_manager
+ .get_attached_tenant_shard(tenant_shard_id)?;
+ tenant.cancel_scheduled_compaction(timeline_id);
+ json_response(StatusCode::OK, ())
+ }
+ .instrument(info_span!("timeline_cancel_compact", tenant_id = %tenant_shard_id.tenant_id, shard_id = %tenant_shard_id.shard_slug(), %timeline_id))
+ .await
+}
+
// Run compaction immediately on given timeline.
async fn timeline_compact_handler(
mut request: Request,
@@ -1987,7 +2007,7 @@ async fn timeline_compact_handler(
let timeline_id: TimelineId = parse_request_param(&request, "timeline_id")?;
check_permission(&request, Some(tenant_shard_id.tenant_id))?;
- let compact_range = json_request_maybe::