LCOV - code coverage report
Current view: top level - libs/pageserver_api/src - config.rs (source / functions) Coverage Total Hit
Test: a43a77853355b937a79c57b07a8f05607cf29e6c.info Lines: 89.4 % 142 127
Test Date: 2024-09-19 12:04:32 Functions: 4.8 % 314 15

            Line data    Source code
       1              : use camino::Utf8PathBuf;
       2              : 
       3              : #[cfg(test)]
       4              : mod tests;
       5              : 
       6              : use const_format::formatcp;
       7              : pub const DEFAULT_PG_LISTEN_PORT: u16 = 64000;
       8              : pub const DEFAULT_PG_LISTEN_ADDR: &str = formatcp!("127.0.0.1:{DEFAULT_PG_LISTEN_PORT}");
       9              : pub const DEFAULT_HTTP_LISTEN_PORT: u16 = 9898;
      10              : pub const DEFAULT_HTTP_LISTEN_ADDR: &str = formatcp!("127.0.0.1:{DEFAULT_HTTP_LISTEN_PORT}");
      11              : 
      12              : use postgres_backend::AuthType;
      13              : use remote_storage::RemoteStorageConfig;
      14              : use serde_with::serde_as;
      15              : use std::{
      16              :     collections::HashMap,
      17              :     num::{NonZeroU64, NonZeroUsize},
      18              :     str::FromStr,
      19              :     time::Duration,
      20              : };
      21              : use utils::logging::LogFormat;
      22              : 
      23              : use crate::models::ImageCompressionAlgorithm;
      24              : use crate::models::LsnLease;
      25              : 
      26              : // Certain metadata (e.g. externally-addressable name, AZ) is delivered
      27              : // as a separate structure.  This information is not neeed by the pageserver
      28              : // itself, it is only used for registering the pageserver with the control
      29              : // plane and/or storage controller.
      30              : //
      31            5 : #[derive(PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
      32              : pub struct NodeMetadata {
      33              :     #[serde(rename = "host")]
      34              :     pub postgres_host: String,
      35              :     #[serde(rename = "port")]
      36              :     pub postgres_port: u16,
      37              :     pub http_host: String,
      38              :     pub http_port: u16,
      39              : 
      40              :     // Deployment tools may write fields to the metadata file beyond what we
      41              :     // use in this type: this type intentionally only names fields that require.
      42              :     #[serde(flatten)]
      43              :     pub other: HashMap<String, serde_json::Value>,
      44              : }
      45              : 
      46              : /// `pageserver.toml`
      47              : ///
      48              : /// We use serde derive with `#[serde(default)]` to generate a deserializer
      49              : /// that fills in the default values for each config field.
      50              : ///
      51              : /// If there cannot be a static default value because we need to make runtime
      52              : /// checks to determine the default, make it an `Option` (which defaults to None).
      53              : /// The runtime check should be done in the consuming crate, i.e., `pageserver`.
      54              : #[serde_as]
      55           78 : #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
      56              : #[serde(default, deny_unknown_fields)]
      57              : pub struct ConfigToml {
      58              :     // types mapped 1:1 into the runtime PageServerConfig type
      59              :     pub listen_pg_addr: String,
      60              :     pub listen_http_addr: String,
      61              :     pub availability_zone: Option<String>,
      62              :     #[serde(with = "humantime_serde")]
      63              :     pub wait_lsn_timeout: Duration,
      64              :     #[serde(with = "humantime_serde")]
      65              :     pub wal_redo_timeout: Duration,
      66              :     pub superuser: String,
      67              :     pub page_cache_size: usize,
      68              :     pub max_file_descriptors: usize,
      69              :     pub pg_distrib_dir: Option<Utf8PathBuf>,
      70              :     #[serde_as(as = "serde_with::DisplayFromStr")]
      71              :     pub http_auth_type: AuthType,
      72              :     #[serde_as(as = "serde_with::DisplayFromStr")]
      73              :     pub pg_auth_type: AuthType,
      74              :     pub auth_validation_public_key_path: Option<Utf8PathBuf>,
      75              :     pub remote_storage: Option<RemoteStorageConfig>,
      76              :     pub tenant_config: TenantConfigToml,
      77              :     #[serde_as(as = "serde_with::DisplayFromStr")]
      78              :     pub broker_endpoint: storage_broker::Uri,
      79              :     #[serde(with = "humantime_serde")]
      80              :     pub broker_keepalive_interval: Duration,
      81              :     #[serde_as(as = "serde_with::DisplayFromStr")]
      82              :     pub log_format: LogFormat,
      83              :     pub concurrent_tenant_warmup: NonZeroUsize,
      84              :     pub concurrent_tenant_size_logical_size_queries: NonZeroUsize,
      85              :     #[serde(with = "humantime_serde")]
      86              :     pub metric_collection_interval: Duration,
      87              :     pub metric_collection_endpoint: Option<reqwest::Url>,
      88              :     pub metric_collection_bucket: Option<RemoteStorageConfig>,
      89              :     #[serde(with = "humantime_serde")]
      90              :     pub synthetic_size_calculation_interval: Duration,
      91              :     pub disk_usage_based_eviction: Option<DiskUsageEvictionTaskConfig>,
      92              :     pub test_remote_failures: u64,
      93              :     pub ondemand_download_behavior_treat_error_as_warn: bool,
      94              :     #[serde(with = "humantime_serde")]
      95              :     pub background_task_maximum_delay: Duration,
      96              :     pub control_plane_api: Option<reqwest::Url>,
      97              :     pub control_plane_api_token: Option<String>,
      98              :     pub control_plane_emergency_mode: bool,
      99              :     pub heatmap_upload_concurrency: usize,
     100              :     pub secondary_download_concurrency: usize,
     101              :     pub virtual_file_io_engine: Option<crate::models::virtual_file::IoEngineKind>,
     102              :     pub ingest_batch_size: u64,
     103              :     pub max_vectored_read_bytes: MaxVectoredReadBytes,
     104              :     pub image_compression: ImageCompressionAlgorithm,
     105              :     pub ephemeral_bytes_per_memory_kb: usize,
     106              :     pub l0_flush: Option<crate::models::L0FlushConfig>,
     107              :     #[serde(skip_serializing)]
     108              :     // TODO(https://github.com/neondatabase/neon/issues/8184): remove after this field is removed from all pageserver.toml's
     109              :     pub compact_level0_phase1_value_access: serde::de::IgnoredAny,
     110              :     pub virtual_file_direct_io: crate::models::virtual_file::DirectIoMode,
     111              :     pub io_buffer_alignment: usize,
     112              : }
     113              : 
     114           12 : #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
     115              : #[serde(deny_unknown_fields)]
     116              : pub struct DiskUsageEvictionTaskConfig {
     117              :     pub max_usage_pct: utils::serde_percent::Percent,
     118              :     pub min_avail_bytes: u64,
     119              :     #[serde(with = "humantime_serde")]
     120              :     pub period: Duration,
     121              :     #[cfg(feature = "testing")]
     122              :     pub mock_statvfs: Option<statvfs::mock::Behavior>,
     123              :     /// Select sorting for evicted layers
     124              :     #[serde(default)]
     125              :     pub eviction_order: EvictionOrder,
     126              : }
     127              : 
     128              : pub mod statvfs {
     129              :     pub mod mock {
     130            0 :         #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
     131              :         #[serde(tag = "type")]
     132              :         pub enum Behavior {
     133              :             Success {
     134              :                 blocksize: u64,
     135              :                 total_blocks: u64,
     136              :                 name_filter: Option<utils::serde_regex::Regex>,
     137              :             },
     138              :             #[cfg(feature = "testing")]
     139              :             Failure { mocked_error: MockedError },
     140              :         }
     141              : 
     142              :         #[cfg(feature = "testing")]
     143            0 :         #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
     144              :         #[allow(clippy::upper_case_acronyms)]
     145              :         pub enum MockedError {
     146              :             EIO,
     147              :         }
     148              : 
     149              :         #[cfg(feature = "testing")]
     150              :         impl From<MockedError> for nix::Error {
     151            0 :             fn from(e: MockedError) -> Self {
     152            0 :                 match e {
     153            0 :                     MockedError::EIO => nix::Error::EIO,
     154            0 :                 }
     155            0 :             }
     156              :         }
     157              :     }
     158              : }
     159              : 
     160            0 : #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
     161              : #[serde(tag = "type", content = "args")]
     162              : pub enum EvictionOrder {
     163              :     RelativeAccessed {
     164              :         highest_layer_count_loses_first: bool,
     165              :     },
     166              : }
     167              : 
     168              : impl Default for EvictionOrder {
     169            6 :     fn default() -> Self {
     170            6 :         Self::RelativeAccessed {
     171            6 :             highest_layer_count_loses_first: true,
     172            6 :         }
     173            6 :     }
     174              : }
     175              : 
     176              : #[derive(
     177              :     Eq,
     178              :     PartialEq,
     179              :     Debug,
     180              :     Copy,
     181              :     Clone,
     182            0 :     strum_macros::EnumString,
     183            0 :     strum_macros::Display,
     184            0 :     serde_with::DeserializeFromStr,
     185              :     serde_with::SerializeDisplay,
     186              : )]
     187              : #[strum(serialize_all = "kebab-case")]
     188              : pub enum GetVectoredImpl {
     189              :     Sequential,
     190              :     Vectored,
     191              : }
     192              : 
     193              : #[derive(
     194              :     Eq,
     195              :     PartialEq,
     196              :     Debug,
     197              :     Copy,
     198              :     Clone,
     199            0 :     strum_macros::EnumString,
     200            0 :     strum_macros::Display,
     201            0 :     serde_with::DeserializeFromStr,
     202              :     serde_with::SerializeDisplay,
     203              : )]
     204              : #[strum(serialize_all = "kebab-case")]
     205              : pub enum GetImpl {
     206              :     Legacy,
     207              :     Vectored,
     208              : }
     209              : 
     210            0 : #[derive(Copy, Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
     211              : #[serde(transparent)]
     212              : pub struct MaxVectoredReadBytes(pub NonZeroUsize);
     213              : 
     214              : /// A tenant's calcuated configuration, which is the result of merging a
     215              : /// tenant's TenantConfOpt with the global TenantConf from PageServerConf.
     216              : ///
     217              : /// For storing and transmitting individual tenant's configuration, see
     218              : /// TenantConfOpt.
     219           12 : #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
     220              : #[serde(deny_unknown_fields, default)]
     221              : pub struct TenantConfigToml {
     222              :     // Flush out an inmemory layer, if it's holding WAL older than this
     223              :     // This puts a backstop on how much WAL needs to be re-digested if the
     224              :     // page server crashes.
     225              :     // This parameter actually determines L0 layer file size.
     226              :     pub checkpoint_distance: u64,
     227              :     // Inmemory layer is also flushed at least once in checkpoint_timeout to
     228              :     // eventually upload WAL after activity is stopped.
     229              :     #[serde(with = "humantime_serde")]
     230              :     pub checkpoint_timeout: Duration,
     231              :     // Target file size, when creating image and delta layers.
     232              :     // This parameter determines L1 layer file size.
     233              :     pub compaction_target_size: u64,
     234              :     // How often to check if there's compaction work to be done.
     235              :     // Duration::ZERO means automatic compaction is disabled.
     236              :     #[serde(with = "humantime_serde")]
     237              :     pub compaction_period: Duration,
     238              :     // Level0 delta layer threshold for compaction.
     239              :     pub compaction_threshold: usize,
     240              :     pub compaction_algorithm: crate::models::CompactionAlgorithmSettings,
     241              :     // Determines how much history is retained, to allow
     242              :     // branching and read replicas at an older point in time.
     243              :     // The unit is #of bytes of WAL.
     244              :     // Page versions older than this are garbage collected away.
     245              :     pub gc_horizon: u64,
     246              :     // Interval at which garbage collection is triggered.
     247              :     // Duration::ZERO means automatic GC is disabled
     248              :     #[serde(with = "humantime_serde")]
     249              :     pub gc_period: Duration,
     250              :     // Delta layer churn threshold to create L1 image layers.
     251              :     pub image_creation_threshold: usize,
     252              :     // Determines how much history is retained, to allow
     253              :     // branching and read replicas at an older point in time.
     254              :     // The unit is time.
     255              :     // Page versions older than this are garbage collected away.
     256              :     #[serde(with = "humantime_serde")]
     257              :     pub pitr_interval: Duration,
     258              :     /// Maximum amount of time to wait while opening a connection to receive wal, before erroring.
     259              :     #[serde(with = "humantime_serde")]
     260              :     pub walreceiver_connect_timeout: Duration,
     261              :     /// Considers safekeepers stalled after no WAL updates were received longer than this threshold.
     262              :     /// A stalled safekeeper will be changed to a newer one when it appears.
     263              :     #[serde(with = "humantime_serde")]
     264              :     pub lagging_wal_timeout: Duration,
     265              :     /// Considers safekeepers lagging when their WAL is behind another safekeeper for more than this threshold.
     266              :     /// A lagging safekeeper will be changed after `lagging_wal_timeout` time elapses since the last WAL update,
     267              :     /// to avoid eager reconnects.
     268              :     pub max_lsn_wal_lag: NonZeroU64,
     269              :     pub eviction_policy: crate::models::EvictionPolicy,
     270              :     pub min_resident_size_override: Option<u64>,
     271              :     // See the corresponding metric's help string.
     272              :     #[serde(with = "humantime_serde")]
     273              :     pub evictions_low_residence_duration_metric_threshold: Duration,
     274              : 
     275              :     /// If non-zero, the period between uploads of a heatmap from attached tenants.  This
     276              :     /// may be disabled if a Tenant will not have secondary locations: only secondary
     277              :     /// locations will use the heatmap uploaded by attached locations.
     278              :     #[serde(with = "humantime_serde")]
     279              :     pub heatmap_period: Duration,
     280              : 
     281              :     /// If true then SLRU segments are dowloaded on demand, if false SLRU segments are included in basebackup
     282              :     pub lazy_slru_download: bool,
     283              : 
     284              :     pub timeline_get_throttle: crate::models::ThrottleConfig,
     285              : 
     286              :     // How much WAL must be ingested before checking again whether a new image layer is required.
     287              :     // Expresed in multiples of checkpoint distance.
     288              :     pub image_layer_creation_check_threshold: u8,
     289              : 
     290              :     /// Switch to a new aux file policy. Switching this flag requires the user has not written any aux file into
     291              :     /// the storage before, and this flag cannot be switched back. Otherwise there will be data corruptions.
     292              :     /// There is a `last_aux_file_policy` flag which gets persisted in `index_part.json` once the first aux
     293              :     /// file is written.
     294              :     pub switch_aux_file_policy: crate::models::AuxFilePolicy,
     295              : 
     296              :     /// The length for an explicit LSN lease request.
     297              :     /// Layers needed to reconstruct pages at LSN will not be GC-ed during this interval.
     298              :     #[serde(with = "humantime_serde")]
     299              :     pub lsn_lease_length: Duration,
     300              : 
     301              :     /// The length for an implicit LSN lease granted as part of `get_lsn_by_timestamp` request.
     302              :     /// Layers needed to reconstruct pages at LSN will not be GC-ed during this interval.
     303              :     #[serde(with = "humantime_serde")]
     304              :     pub lsn_lease_length_for_ts: Duration,
     305              : }
     306              : 
     307              : pub mod defaults {
     308              :     use crate::models::ImageCompressionAlgorithm;
     309              : 
     310              :     pub use storage_broker::DEFAULT_ENDPOINT as BROKER_DEFAULT_ENDPOINT;
     311              : 
     312              :     pub const DEFAULT_WAIT_LSN_TIMEOUT: &str = "300 s";
     313              :     pub const DEFAULT_WAL_REDO_TIMEOUT: &str = "60 s";
     314              : 
     315              :     pub const DEFAULT_SUPERUSER: &str = "cloud_admin";
     316              : 
     317              :     pub const DEFAULT_PAGE_CACHE_SIZE: usize = 8192;
     318              :     pub const DEFAULT_MAX_FILE_DESCRIPTORS: usize = 100;
     319              : 
     320              :     pub const DEFAULT_LOG_FORMAT: &str = "plain";
     321              : 
     322              :     pub const DEFAULT_CONCURRENT_TENANT_WARMUP: usize = 8;
     323              : 
     324              :     pub const DEFAULT_CONCURRENT_TENANT_SIZE_LOGICAL_SIZE_QUERIES: usize = 1;
     325              : 
     326              :     pub const DEFAULT_METRIC_COLLECTION_INTERVAL: &str = "10 min";
     327              :     pub const DEFAULT_METRIC_COLLECTION_ENDPOINT: Option<reqwest::Url> = None;
     328              :     pub const DEFAULT_SYNTHETIC_SIZE_CALCULATION_INTERVAL: &str = "10 min";
     329              :     pub const DEFAULT_BACKGROUND_TASK_MAXIMUM_DELAY: &str = "10s";
     330              : 
     331              :     pub const DEFAULT_HEATMAP_UPLOAD_CONCURRENCY: usize = 8;
     332              :     pub const DEFAULT_SECONDARY_DOWNLOAD_CONCURRENCY: usize = 1;
     333              : 
     334              :     pub const DEFAULT_INGEST_BATCH_SIZE: u64 = 100;
     335              : 
     336              :     pub const DEFAULT_MAX_VECTORED_READ_BYTES: usize = 128 * 1024; // 128 KiB
     337              : 
     338              :     pub const DEFAULT_IMAGE_COMPRESSION: ImageCompressionAlgorithm =
     339              :         ImageCompressionAlgorithm::Zstd { level: Some(1) };
     340              : 
     341              :     pub const DEFAULT_VALIDATE_VECTORED_GET: bool = false;
     342              : 
     343              :     pub const DEFAULT_EPHEMERAL_BYTES_PER_MEMORY_KB: usize = 0;
     344              : 
     345              :     pub const DEFAULT_IO_BUFFER_ALIGNMENT: usize = 512;
     346              : }
     347              : 
     348              : impl Default for ConfigToml {
     349          618 :     fn default() -> Self {
     350              :         use defaults::*;
     351              : 
     352          618 :         Self {
     353          618 :             listen_pg_addr: (DEFAULT_PG_LISTEN_ADDR.to_string()),
     354          618 :             listen_http_addr: (DEFAULT_HTTP_LISTEN_ADDR.to_string()),
     355          618 :             availability_zone: (None),
     356          618 :             wait_lsn_timeout: (humantime::parse_duration(DEFAULT_WAIT_LSN_TIMEOUT)
     357          618 :                 .expect("cannot parse default wait lsn timeout")),
     358          618 :             wal_redo_timeout: (humantime::parse_duration(DEFAULT_WAL_REDO_TIMEOUT)
     359          618 :                 .expect("cannot parse default wal redo timeout")),
     360          618 :             superuser: (DEFAULT_SUPERUSER.to_string()),
     361          618 :             page_cache_size: (DEFAULT_PAGE_CACHE_SIZE),
     362          618 :             max_file_descriptors: (DEFAULT_MAX_FILE_DESCRIPTORS),
     363          618 :             pg_distrib_dir: None, // Utf8PathBuf::from("./pg_install"), // TODO: formely, this was std::env::current_dir()
     364          618 :             http_auth_type: (AuthType::Trust),
     365          618 :             pg_auth_type: (AuthType::Trust),
     366          618 :             auth_validation_public_key_path: (None),
     367          618 :             remote_storage: None,
     368          618 :             broker_endpoint: (storage_broker::DEFAULT_ENDPOINT
     369          618 :                 .parse()
     370          618 :                 .expect("failed to parse default broker endpoint")),
     371          618 :             broker_keepalive_interval: (humantime::parse_duration(
     372          618 :                 storage_broker::DEFAULT_KEEPALIVE_INTERVAL,
     373          618 :             )
     374          618 :             .expect("cannot parse default keepalive interval")),
     375          618 :             log_format: (LogFormat::from_str(DEFAULT_LOG_FORMAT).unwrap()),
     376          618 : 
     377          618 :             concurrent_tenant_warmup: (NonZeroUsize::new(DEFAULT_CONCURRENT_TENANT_WARMUP)
     378          618 :                 .expect("Invalid default constant")),
     379          618 :             concurrent_tenant_size_logical_size_queries: NonZeroUsize::new(1).unwrap(),
     380          618 :             metric_collection_interval: (humantime::parse_duration(
     381          618 :                 DEFAULT_METRIC_COLLECTION_INTERVAL,
     382          618 :             )
     383          618 :             .expect("cannot parse default metric collection interval")),
     384          618 :             synthetic_size_calculation_interval: (humantime::parse_duration(
     385          618 :                 DEFAULT_SYNTHETIC_SIZE_CALCULATION_INTERVAL,
     386          618 :             )
     387          618 :             .expect("cannot parse default synthetic size calculation interval")),
     388          618 :             metric_collection_endpoint: (DEFAULT_METRIC_COLLECTION_ENDPOINT),
     389          618 : 
     390          618 :             metric_collection_bucket: (None),
     391          618 : 
     392          618 :             disk_usage_based_eviction: (None),
     393          618 : 
     394          618 :             test_remote_failures: (0),
     395          618 : 
     396          618 :             ondemand_download_behavior_treat_error_as_warn: (false),
     397          618 : 
     398          618 :             background_task_maximum_delay: (humantime::parse_duration(
     399          618 :                 DEFAULT_BACKGROUND_TASK_MAXIMUM_DELAY,
     400          618 :             )
     401          618 :             .unwrap()),
     402          618 : 
     403          618 :             control_plane_api: (None),
     404          618 :             control_plane_api_token: (None),
     405          618 :             control_plane_emergency_mode: (false),
     406          618 : 
     407          618 :             heatmap_upload_concurrency: (DEFAULT_HEATMAP_UPLOAD_CONCURRENCY),
     408          618 :             secondary_download_concurrency: (DEFAULT_SECONDARY_DOWNLOAD_CONCURRENCY),
     409          618 : 
     410          618 :             ingest_batch_size: (DEFAULT_INGEST_BATCH_SIZE),
     411          618 : 
     412          618 :             virtual_file_io_engine: None,
     413          618 : 
     414          618 :             max_vectored_read_bytes: (MaxVectoredReadBytes(
     415          618 :                 NonZeroUsize::new(DEFAULT_MAX_VECTORED_READ_BYTES).unwrap(),
     416          618 :             )),
     417          618 :             image_compression: (DEFAULT_IMAGE_COMPRESSION),
     418          618 :             ephemeral_bytes_per_memory_kb: (DEFAULT_EPHEMERAL_BYTES_PER_MEMORY_KB),
     419          618 :             l0_flush: None,
     420          618 :             compact_level0_phase1_value_access: Default::default(),
     421          618 :             virtual_file_direct_io: crate::models::virtual_file::DirectIoMode::default(),
     422          618 : 
     423          618 :             io_buffer_alignment: DEFAULT_IO_BUFFER_ALIGNMENT,
     424          618 : 
     425          618 :             tenant_config: TenantConfigToml::default(),
     426          618 :         }
     427          618 :     }
     428              : }
     429              : 
     430              : pub mod tenant_conf_defaults {
     431              : 
     432              :     // FIXME: This current value is very low. I would imagine something like 1 GB or 10 GB
     433              :     // would be more appropriate. But a low value forces the code to be exercised more,
     434              :     // which is good for now to trigger bugs.
     435              :     // This parameter actually determines L0 layer file size.
     436              :     pub const DEFAULT_CHECKPOINT_DISTANCE: u64 = 256 * 1024 * 1024;
     437              :     pub const DEFAULT_CHECKPOINT_TIMEOUT: &str = "10 m";
     438              : 
     439              :     // FIXME the below configs are only used by legacy algorithm. The new algorithm
     440              :     // has different parameters.
     441              : 
     442              :     // Target file size, when creating image and delta layers.
     443              :     // This parameter determines L1 layer file size.
     444              :     pub const DEFAULT_COMPACTION_TARGET_SIZE: u64 = 128 * 1024 * 1024;
     445              : 
     446              :     pub const DEFAULT_COMPACTION_PERIOD: &str = "20 s";
     447              :     pub const DEFAULT_COMPACTION_THRESHOLD: usize = 10;
     448              :     pub const DEFAULT_COMPACTION_ALGORITHM: crate::models::CompactionAlgorithm =
     449              :         crate::models::CompactionAlgorithm::Legacy;
     450              : 
     451              :     pub const DEFAULT_GC_HORIZON: u64 = 64 * 1024 * 1024;
     452              : 
     453              :     // Large DEFAULT_GC_PERIOD is fine as long as PITR_INTERVAL is larger.
     454              :     // If there's a need to decrease this value, first make sure that GC
     455              :     // doesn't hold a layer map write lock for non-trivial operations.
     456              :     // Relevant: https://github.com/neondatabase/neon/issues/3394
     457              :     pub const DEFAULT_GC_PERIOD: &str = "1 hr";
     458              :     pub const DEFAULT_IMAGE_CREATION_THRESHOLD: usize = 3;
     459              :     pub const DEFAULT_PITR_INTERVAL: &str = "7 days";
     460              :     pub const DEFAULT_WALRECEIVER_CONNECT_TIMEOUT: &str = "10 seconds";
     461              :     pub const DEFAULT_WALRECEIVER_LAGGING_WAL_TIMEOUT: &str = "10 seconds";
     462              :     // The default limit on WAL lag should be set to avoid causing disconnects under high throughput
     463              :     // scenarios: since the broker stats are updated ~1/s, a value of 1GiB should be sufficient for
     464              :     // throughputs up to 1GiB/s per timeline.
     465              :     pub const DEFAULT_MAX_WALRECEIVER_LSN_WAL_LAG: u64 = 1024 * 1024 * 1024;
     466              :     pub const DEFAULT_EVICTIONS_LOW_RESIDENCE_DURATION_METRIC_THRESHOLD: &str = "24 hour";
     467              :     // By default ingest enough WAL for two new L0 layers before checking if new image
     468              :     // image layers should be created.
     469              :     pub const DEFAULT_IMAGE_LAYER_CREATION_CHECK_THRESHOLD: u8 = 2;
     470              : 
     471              :     pub const DEFAULT_INGEST_BATCH_SIZE: u64 = 100;
     472              : }
     473              : 
     474              : impl Default for TenantConfigToml {
     475         1158 :     fn default() -> Self {
     476              :         use tenant_conf_defaults::*;
     477         1158 :         Self {
     478         1158 :             checkpoint_distance: DEFAULT_CHECKPOINT_DISTANCE,
     479         1158 :             checkpoint_timeout: humantime::parse_duration(DEFAULT_CHECKPOINT_TIMEOUT)
     480         1158 :                 .expect("cannot parse default checkpoint timeout"),
     481         1158 :             compaction_target_size: DEFAULT_COMPACTION_TARGET_SIZE,
     482         1158 :             compaction_period: humantime::parse_duration(DEFAULT_COMPACTION_PERIOD)
     483         1158 :                 .expect("cannot parse default compaction period"),
     484         1158 :             compaction_threshold: DEFAULT_COMPACTION_THRESHOLD,
     485         1158 :             compaction_algorithm: crate::models::CompactionAlgorithmSettings {
     486         1158 :                 kind: DEFAULT_COMPACTION_ALGORITHM,
     487         1158 :             },
     488         1158 :             gc_horizon: DEFAULT_GC_HORIZON,
     489         1158 :             gc_period: humantime::parse_duration(DEFAULT_GC_PERIOD)
     490         1158 :                 .expect("cannot parse default gc period"),
     491         1158 :             image_creation_threshold: DEFAULT_IMAGE_CREATION_THRESHOLD,
     492         1158 :             pitr_interval: humantime::parse_duration(DEFAULT_PITR_INTERVAL)
     493         1158 :                 .expect("cannot parse default PITR interval"),
     494         1158 :             walreceiver_connect_timeout: humantime::parse_duration(
     495         1158 :                 DEFAULT_WALRECEIVER_CONNECT_TIMEOUT,
     496         1158 :             )
     497         1158 :             .expect("cannot parse default walreceiver connect timeout"),
     498         1158 :             lagging_wal_timeout: humantime::parse_duration(DEFAULT_WALRECEIVER_LAGGING_WAL_TIMEOUT)
     499         1158 :                 .expect("cannot parse default walreceiver lagging wal timeout"),
     500         1158 :             max_lsn_wal_lag: NonZeroU64::new(DEFAULT_MAX_WALRECEIVER_LSN_WAL_LAG)
     501         1158 :                 .expect("cannot parse default max walreceiver Lsn wal lag"),
     502         1158 :             eviction_policy: crate::models::EvictionPolicy::NoEviction,
     503         1158 :             min_resident_size_override: None,
     504         1158 :             evictions_low_residence_duration_metric_threshold: humantime::parse_duration(
     505         1158 :                 DEFAULT_EVICTIONS_LOW_RESIDENCE_DURATION_METRIC_THRESHOLD,
     506         1158 :             )
     507         1158 :             .expect("cannot parse default evictions_low_residence_duration_metric_threshold"),
     508         1158 :             heatmap_period: Duration::ZERO,
     509         1158 :             lazy_slru_download: false,
     510         1158 :             timeline_get_throttle: crate::models::ThrottleConfig::disabled(),
     511         1158 :             image_layer_creation_check_threshold: DEFAULT_IMAGE_LAYER_CREATION_CHECK_THRESHOLD,
     512         1158 :             switch_aux_file_policy: crate::models::AuxFilePolicy::default_tenant_config(),
     513         1158 :             lsn_lease_length: LsnLease::DEFAULT_LENGTH,
     514         1158 :             lsn_lease_length_for_ts: LsnLease::DEFAULT_LENGTH_FOR_TS,
     515         1158 :         }
     516         1158 :     }
     517              : }
        

Generated by: LCOV version 2.1-beta