From af210c8b42da3b57f4750d41cba0e7b4047aa92a Mon Sep 17 00:00:00 2001 From: Shany Pozin Date: Mon, 20 Feb 2023 13:23:13 +0200 Subject: [PATCH] Allow running do_gc in non testing env (#3639) ## Describe your changes Since the current default gc period is set to 1 hour, whenever there is an immediate need to reduce PITR and run gc, the user has to wait 1 hour for PITR change to take effect By enabling this API the user can configure PITR and immediately call the do_gc API to trigger gc ## Issue ticket number and link #3590 ## Checklist before requesting a review - [X] I have performed a self-review of my code. - [ ] If it is a core feature, I have added thorough tests. - [ ] Do we need to implement analytics? if so did you add the relevant metrics to the dashboard? - [ ] If this PR requires public announcement, mark it with /release-notes label and add several sentences in this section. --- pageserver/src/http/routes.rs | 7 +++---- pageserver/src/tenant/mgr.rs | 2 -- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/pageserver/src/http/routes.rs b/pageserver/src/http/routes.rs index 71273159b7..d2d9f24efb 100644 --- a/pageserver/src/http/routes.rs +++ b/pageserver/src/http/routes.rs @@ -14,7 +14,7 @@ use utils::http::request::{get_request_param, must_get_query_param, parse_query_ use super::models::{ StatusResponse, TenantConfigRequest, TenantCreateRequest, TenantCreateResponse, TenantInfo, - TimelineCreateRequest, TimelineInfo, + TimelineCreateRequest, TimelineGcRequest, TimelineInfo, }; use crate::context::{DownloadBehavior, RequestContext}; use crate::pgdatadir_mapping::LsnForTimestamp; @@ -40,7 +40,7 @@ use utils::{ // Imports only used for testing APIs #[cfg(feature = "testing")] -use super::models::{ConfigureFailpointsRequest, TimelineGcRequest}; +use super::models::ConfigureFailpointsRequest; struct State { conf: &'static PageServerConf, @@ -925,7 +925,6 @@ async fn failpoints_handler(mut request: Request) -> Result } // Run GC immediately on given timeline. -#[cfg(feature = "testing")] async fn timeline_gc_handler(mut request: Request) -> Result, ApiError> { let tenant_id: TenantId = parse_request_param(&request, "tenant_id")?; let timeline_id: TimelineId = parse_request_param(&request, "timeline_id")?; @@ -1124,7 +1123,7 @@ pub fn make_router( ) .put( "/v1/tenant/:tenant_id/timeline/:timeline_id/do_gc", - testing_api!("run timeline GC", timeline_gc_handler), + timeline_gc_handler, ) .put( "/v1/tenant/:tenant_id/timeline/:timeline_id/compact", diff --git a/pageserver/src/tenant/mgr.rs b/pageserver/src/tenant/mgr.rs index a74dfdea04..a44cb02b4d 100644 --- a/pageserver/src/tenant/mgr.rs +++ b/pageserver/src/tenant/mgr.rs @@ -540,13 +540,11 @@ where } } -#[cfg(feature = "testing")] use { crate::repository::GcResult, pageserver_api::models::TimelineGcRequest, utils::http::error::ApiError, }; -#[cfg(feature = "testing")] pub async fn immediate_gc( tenant_id: TenantId, timeline_id: TimelineId,