From b59975504299f82606da1174632a954177d3cd4f Mon Sep 17 00:00:00 2001 From: Joonas Koivunen Date: Tue, 28 Mar 2023 10:30:36 +0300 Subject: [PATCH] refactor: rename DiskUsageEvictionState => State --- pageserver/src/bin/pageserver.rs | 6 ++---- pageserver/src/disk_usage_eviction_task.rs | 12 ++++++------ pageserver/src/http/routes.rs | 8 ++++---- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/pageserver/src/bin/pageserver.rs b/pageserver/src/bin/pageserver.rs index 7dcf6465e2..735b7124f1 100644 --- a/pageserver/src/bin/pageserver.rs +++ b/pageserver/src/bin/pageserver.rs @@ -8,9 +8,7 @@ use anyhow::{anyhow, Context}; use clap::{Arg, ArgAction, Command}; use fail::FailScenario; use metrics::launch_timestamp::{set_launch_timestamp_metric, LaunchTimestamp}; -use pageserver::disk_usage_eviction_task::{ - launch_disk_usage_global_eviction_task, DiskUsageEvictionState, -}; +use pageserver::disk_usage_eviction_task::{self, launch_disk_usage_global_eviction_task}; use remote_storage::GenericRemoteStorage; use tracing::*; @@ -326,7 +324,7 @@ fn start_pageserver( // that allows triggering disk-usage based eviction manually. note that the http endpoint // is still accessible even if background task is not configured as long as remote storage has // been configured. - let disk_usage_eviction_state: Arc = Arc::default(); + let disk_usage_eviction_state: Arc = Arc::default(); if let Some(remote_storage) = &remote_storage { launch_disk_usage_global_eviction_task( diff --git a/pageserver/src/disk_usage_eviction_task.rs b/pageserver/src/disk_usage_eviction_task.rs index e0083c11bb..cbaae72133 100644 --- a/pageserver/src/disk_usage_eviction_task.rs +++ b/pageserver/src/disk_usage_eviction_task.rs @@ -71,15 +71,15 @@ pub struct DiskUsageEvictionTaskConfig { } #[derive(Default)] -pub struct DiskUsageEvictionState { - /// Prevent mgmt API requests and the background loop from running eviction at the same time. +pub struct State { + /// Exclude http requests and background task from running at the same time. mutex: tokio::sync::Mutex<()>, } pub fn launch_disk_usage_global_eviction_task( conf: &'static PageServerConf, storage: GenericRemoteStorage, - state: Arc, + state: Arc, ) -> anyhow::Result<()> { let Some(task_config) = &conf.disk_usage_based_eviction else { info!("disk usage based eviction task not configured"); @@ -124,7 +124,7 @@ pub fn launch_disk_usage_global_eviction_task( #[instrument(skip_all)] async fn disk_usage_eviction_task( - state: &DiskUsageEvictionState, + state: &State, task_config: &DiskUsageEvictionTaskConfig, storage: GenericRemoteStorage, tenants_dir_fd: Dir, @@ -192,7 +192,7 @@ pub trait Usage: Clone + Copy + std::fmt::Debug { } async fn disk_usage_eviction_task_iteration( - state: &DiskUsageEvictionState, + state: &State, task_config: &DiskUsageEvictionTaskConfig, storage: &GenericRemoteStorage, tenants_dir_fd: &mut SyncWrapper, @@ -284,7 +284,7 @@ struct LayerCount { #[allow(clippy::needless_late_init)] pub async fn disk_usage_eviction_task_iteration_impl( - state: &DiskUsageEvictionState, + state: &State, storage: &GenericRemoteStorage, usage_pre: U, cancel: &CancellationToken, diff --git a/pageserver/src/http/routes.rs b/pageserver/src/http/routes.rs index d0ed97fefe..6699f6e5d4 100644 --- a/pageserver/src/http/routes.rs +++ b/pageserver/src/http/routes.rs @@ -18,7 +18,7 @@ use super::models::{ TimelineCreateRequest, TimelineGcRequest, TimelineInfo, }; use crate::context::{DownloadBehavior, RequestContext}; -use crate::disk_usage_eviction_task::DiskUsageEvictionState; +use crate::disk_usage_eviction_task; use crate::pgdatadir_mapping::LsnForTimestamp; use crate::task_mgr::TaskKind; use crate::tenant::config::TenantConfOpt; @@ -49,7 +49,7 @@ struct State { auth: Option>, allowlist_routes: Vec, remote_storage: Option, - disk_usage_eviction_state: Arc, + disk_usage_eviction_state: Arc, } impl State { @@ -57,7 +57,7 @@ impl State { conf: &'static PageServerConf, auth: Option>, remote_storage: Option, - disk_usage_eviction_state: Arc, + disk_usage_eviction_state: Arc, ) -> anyhow::Result { let allowlist_routes = ["/v1/status", "/v1/doc", "/swagger.yml"] .iter() @@ -1175,7 +1175,7 @@ pub fn make_router( launch_ts: &'static LaunchTimestamp, auth: Option>, remote_storage: Option, - disk_usage_eviction_state: Arc, + disk_usage_eviction_state: Arc, ) -> anyhow::Result> { let spec = include_bytes!("openapi_spec.yml"); let mut router = attach_openapi_ui(endpoint::make_router(), spec, "/swagger.yml", "/v1/doc");