diff --git a/pageserver/src/tenant/timeline/delete.rs b/pageserver/src/tenant/timeline/delete.rs index d2272fc75f..6f5779fd14 100644 --- a/pageserver/src/tenant/timeline/delete.rs +++ b/pageserver/src/tenant/timeline/delete.rs @@ -26,6 +26,10 @@ use crate::{ use super::{Timeline, TimelineResources}; /// Now that the Timeline is in Stopping state, request all the related tasks to shut down. +/// +/// This is essentially a hand-crafted subset of Timeline::shutdown, which exists because we +/// rely on keeping Timeline partially alive in order to access its RemoteTimelineClient for remote +/// deletion. async fn stop_tasks(timeline: &Timeline) -> Result<(), DeleteTimelineError> { debug_assert_current_span_has_tenant_and_timeline_id(); // Notify any timeline work to drop out of loops/requests @@ -82,6 +86,8 @@ async fn stop_tasks(timeline: &Timeline) -> Result<(), DeleteTimelineError> { ))? }); + timeline.metrics.shutdown(); + tracing::debug!("Waiting for gate..."); timeline.gate.close().await; tracing::debug!("Shutdown complete"); diff --git a/test_runner/regress/test_timeline_delete.py b/test_runner/regress/test_timeline_delete.py index 0eb1327c9e..a7340aac84 100644 --- a/test_runner/regress/test_timeline_delete.py +++ b/test_runner/regress/test_timeline_delete.py @@ -88,6 +88,14 @@ def test_timeline_delete(neon_simple_env: NeonEnv): timeline_path = env.pageserver.timeline_dir(env.initial_tenant, leaf_timeline_id) assert timeline_path.exists() + # Before deleting, timeline metrics should be present + assert ( + ps_http.get_metric_value( + "pageserver_current_logical_size", {"timeline_id": str(leaf_timeline_id)} + ) + is not None + ) + # retry deletes when compaction or gc is running in pageserver # TODO: review whether this wait_until is actually necessary, we do an await() internally wait_until( @@ -106,6 +114,14 @@ def test_timeline_delete(neon_simple_env: NeonEnv): ps_http.timeline_detail(env.initial_tenant, leaf_timeline_id) assert exc.value.status_code == 404 + # Check metrics were cleaned up + assert ( + ps_http.get_metric_value( + "pageserver_current_logical_size", {"timeline_id": str(leaf_timeline_id)} + ) + is None + ) + wait_until( number_of_iterations=3, interval=0.2,