LCOV - code coverage report
Current view: top level - libs/pageserver_api/src - config.rs (source / functions) Coverage Total Hit
Test: 49aa928ec5b4b510172d8b5c6d154da28e70a46c.info Lines: 93.5 % 138 129
Test Date: 2024-11-13 18:23:39 Functions: 5.0 % 302 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           22 : #[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 locale: String,
      68              :     pub page_cache_size: usize,
      69              :     pub max_file_descriptors: usize,
      70              :     pub pg_distrib_dir: Option<Utf8PathBuf>,
      71              :     #[serde_as(as = "serde_with::DisplayFromStr")]
      72              :     pub http_auth_type: AuthType,
      73              :     #[serde_as(as = "serde_with::DisplayFromStr")]
      74              :     pub pg_auth_type: AuthType,
      75              :     pub auth_validation_public_key_path: Option<Utf8PathBuf>,
      76              :     pub remote_storage: Option<RemoteStorageConfig>,
      77              :     pub tenant_config: TenantConfigToml,
      78              :     #[serde_as(as = "serde_with::DisplayFromStr")]
      79              :     pub broker_endpoint: storage_broker::Uri,
      80              :     #[serde(with = "humantime_serde")]
      81              :     pub broker_keepalive_interval: Duration,
      82              :     #[serde_as(as = "serde_with::DisplayFromStr")]
      83              :     pub log_format: LogFormat,
      84              :     pub concurrent_tenant_warmup: NonZeroUsize,
      85              :     pub concurrent_tenant_size_logical_size_queries: NonZeroUsize,
      86              :     #[serde(with = "humantime_serde")]
      87              :     pub metric_collection_interval: Duration,
      88              :     pub metric_collection_endpoint: Option<reqwest::Url>,
      89              :     pub metric_collection_bucket: Option<RemoteStorageConfig>,
      90              :     #[serde(with = "humantime_serde")]
      91              :     pub synthetic_size_calculation_interval: Duration,
      92              :     pub disk_usage_based_eviction: Option<DiskUsageEvictionTaskConfig>,
      93              :     pub test_remote_failures: u64,
      94              :     pub ondemand_download_behavior_treat_error_as_warn: bool,
      95              :     #[serde(with = "humantime_serde")]
      96              :     pub background_task_maximum_delay: Duration,
      97              :     pub control_plane_api: Option<reqwest::Url>,
      98              :     pub control_plane_api_token: Option<String>,
      99              :     pub control_plane_emergency_mode: bool,
     100              :     pub heatmap_upload_concurrency: usize,
     101              :     pub secondary_download_concurrency: usize,
     102              :     pub virtual_file_io_engine: Option<crate::models::virtual_file::IoEngineKind>,
     103              :     pub ingest_batch_size: u64,
     104              :     pub max_vectored_read_bytes: MaxVectoredReadBytes,
     105              :     pub image_compression: ImageCompressionAlgorithm,
     106              :     pub timeline_offloading: bool,
     107              :     pub ephemeral_bytes_per_memory_kb: usize,
     108              :     pub l0_flush: Option<crate::models::L0FlushConfig>,
     109              :     pub virtual_file_io_mode: Option<crate::models::virtual_file::IoMode>,
     110              :     #[serde(skip_serializing_if = "Option::is_none")]
     111              :     pub no_sync: Option<bool>,
     112              : }
     113              : 
     114            4 : #[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            2 :     fn default() -> Self {
     170            2 :         Self::RelativeAccessed {
     171            2 :             highest_layer_count_loses_first: true,
     172            2 :         }
     173            2 :     }
     174              : }
     175              : 
     176            0 : #[derive(Copy, Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
     177              : #[serde(transparent)]
     178              : pub struct MaxVectoredReadBytes(pub NonZeroUsize);
     179              : 
     180              : /// A tenant's calcuated configuration, which is the result of merging a
     181              : /// tenant's TenantConfOpt with the global TenantConf from PageServerConf.
     182              : ///
     183              : /// For storing and transmitting individual tenant's configuration, see
     184              : /// TenantConfOpt.
     185            4 : #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
     186              : #[serde(deny_unknown_fields, default)]
     187              : pub struct TenantConfigToml {
     188              :     // Flush out an inmemory layer, if it's holding WAL older than this
     189              :     // This puts a backstop on how much WAL needs to be re-digested if the
     190              :     // page server crashes.
     191              :     // This parameter actually determines L0 layer file size.
     192              :     pub checkpoint_distance: u64,
     193              :     // Inmemory layer is also flushed at least once in checkpoint_timeout to
     194              :     // eventually upload WAL after activity is stopped.
     195              :     #[serde(with = "humantime_serde")]
     196              :     pub checkpoint_timeout: Duration,
     197              :     // Target file size, when creating image and delta layers.
     198              :     // This parameter determines L1 layer file size.
     199              :     pub compaction_target_size: u64,
     200              :     // How often to check if there's compaction work to be done.
     201              :     // Duration::ZERO means automatic compaction is disabled.
     202              :     #[serde(with = "humantime_serde")]
     203              :     pub compaction_period: Duration,
     204              :     // Level0 delta layer threshold for compaction.
     205              :     pub compaction_threshold: usize,
     206              :     pub compaction_algorithm: crate::models::CompactionAlgorithmSettings,
     207              :     // Determines how much history is retained, to allow
     208              :     // branching and read replicas at an older point in time.
     209              :     // The unit is #of bytes of WAL.
     210              :     // Page versions older than this are garbage collected away.
     211              :     pub gc_horizon: u64,
     212              :     // Interval at which garbage collection is triggered.
     213              :     // Duration::ZERO means automatic GC is disabled
     214              :     #[serde(with = "humantime_serde")]
     215              :     pub gc_period: Duration,
     216              :     // Delta layer churn threshold to create L1 image layers.
     217              :     pub image_creation_threshold: usize,
     218              :     // Determines how much history is retained, to allow
     219              :     // branching and read replicas at an older point in time.
     220              :     // The unit is time.
     221              :     // Page versions older than this are garbage collected away.
     222              :     #[serde(with = "humantime_serde")]
     223              :     pub pitr_interval: Duration,
     224              :     /// Maximum amount of time to wait while opening a connection to receive wal, before erroring.
     225              :     #[serde(with = "humantime_serde")]
     226              :     pub walreceiver_connect_timeout: Duration,
     227              :     /// Considers safekeepers stalled after no WAL updates were received longer than this threshold.
     228              :     /// A stalled safekeeper will be changed to a newer one when it appears.
     229              :     #[serde(with = "humantime_serde")]
     230              :     pub lagging_wal_timeout: Duration,
     231              :     /// Considers safekeepers lagging when their WAL is behind another safekeeper for more than this threshold.
     232              :     /// A lagging safekeeper will be changed after `lagging_wal_timeout` time elapses since the last WAL update,
     233              :     /// to avoid eager reconnects.
     234              :     pub max_lsn_wal_lag: NonZeroU64,
     235              :     pub eviction_policy: crate::models::EvictionPolicy,
     236              :     pub min_resident_size_override: Option<u64>,
     237              :     // See the corresponding metric's help string.
     238              :     #[serde(with = "humantime_serde")]
     239              :     pub evictions_low_residence_duration_metric_threshold: Duration,
     240              : 
     241              :     /// If non-zero, the period between uploads of a heatmap from attached tenants.  This
     242              :     /// may be disabled if a Tenant will not have secondary locations: only secondary
     243              :     /// locations will use the heatmap uploaded by attached locations.
     244              :     #[serde(with = "humantime_serde")]
     245              :     pub heatmap_period: Duration,
     246              : 
     247              :     /// If true then SLRU segments are dowloaded on demand, if false SLRU segments are included in basebackup
     248              :     pub lazy_slru_download: bool,
     249              : 
     250              :     pub timeline_get_throttle: crate::models::ThrottleConfig,
     251              : 
     252              :     // How much WAL must be ingested before checking again whether a new image layer is required.
     253              :     // Expresed in multiples of checkpoint distance.
     254              :     pub image_layer_creation_check_threshold: u8,
     255              : 
     256              :     /// The length for an explicit LSN lease request.
     257              :     /// Layers needed to reconstruct pages at LSN will not be GC-ed during this interval.
     258              :     #[serde(with = "humantime_serde")]
     259              :     pub lsn_lease_length: Duration,
     260              : 
     261              :     /// The length for an implicit LSN lease granted as part of `get_lsn_by_timestamp` request.
     262              :     /// Layers needed to reconstruct pages at LSN will not be GC-ed during this interval.
     263              :     #[serde(with = "humantime_serde")]
     264              :     pub lsn_lease_length_for_ts: Duration,
     265              : 
     266              :     /// Enable auto-offloading of timelines.
     267              :     /// (either this flag or the pageserver-global one need to be set)
     268              :     pub timeline_offloading: bool,
     269              : }
     270              : 
     271              : pub mod defaults {
     272              :     use crate::models::ImageCompressionAlgorithm;
     273              : 
     274              :     pub use storage_broker::DEFAULT_ENDPOINT as BROKER_DEFAULT_ENDPOINT;
     275              : 
     276              :     pub const DEFAULT_WAIT_LSN_TIMEOUT: &str = "300 s";
     277              :     pub const DEFAULT_WAL_REDO_TIMEOUT: &str = "60 s";
     278              : 
     279              :     pub const DEFAULT_SUPERUSER: &str = "cloud_admin";
     280              :     pub const DEFAULT_LOCALE: &str = if cfg!(target_os = "macos") {
     281              :         "C"
     282              :     } else {
     283              :         "C.UTF-8"
     284              :     };
     285              : 
     286              :     pub const DEFAULT_PAGE_CACHE_SIZE: usize = 8192;
     287              :     pub const DEFAULT_MAX_FILE_DESCRIPTORS: usize = 100;
     288              : 
     289              :     pub const DEFAULT_LOG_FORMAT: &str = "plain";
     290              : 
     291              :     pub const DEFAULT_CONCURRENT_TENANT_WARMUP: usize = 8;
     292              : 
     293              :     pub const DEFAULT_CONCURRENT_TENANT_SIZE_LOGICAL_SIZE_QUERIES: usize = 1;
     294              : 
     295              :     pub const DEFAULT_METRIC_COLLECTION_INTERVAL: &str = "10 min";
     296              :     pub const DEFAULT_METRIC_COLLECTION_ENDPOINT: Option<reqwest::Url> = None;
     297              :     pub const DEFAULT_SYNTHETIC_SIZE_CALCULATION_INTERVAL: &str = "10 min";
     298              :     pub const DEFAULT_BACKGROUND_TASK_MAXIMUM_DELAY: &str = "10s";
     299              : 
     300              :     pub const DEFAULT_HEATMAP_UPLOAD_CONCURRENCY: usize = 8;
     301              :     pub const DEFAULT_SECONDARY_DOWNLOAD_CONCURRENCY: usize = 1;
     302              : 
     303              :     pub const DEFAULT_INGEST_BATCH_SIZE: u64 = 100;
     304              : 
     305              :     /// Soft limit for the maximum size of a vectored read.
     306              :     ///
     307              :     /// This is determined by the largest NeonWalRecord that can exist (minus dbdir and reldir keys
     308              :     /// which are bounded by the blob io limits only). As of this writing, that is a `NeonWalRecord::ClogSetCommitted` record,
     309              :     /// with 32k xids. That's the max number of XIDS on a single CLOG page. The size of such a record
     310              :     /// is `sizeof(Transactionid) * 32768 + (some fixed overhead from 'timestamp`, the Vec length and whatever extra serde serialization adds)`.
     311              :     /// That is, slightly above 128 kB.
     312              :     pub const DEFAULT_MAX_VECTORED_READ_BYTES: usize = 130 * 1024; // 130 KiB
     313              : 
     314              :     pub const DEFAULT_IMAGE_COMPRESSION: ImageCompressionAlgorithm =
     315              :         ImageCompressionAlgorithm::Zstd { level: Some(1) };
     316              : 
     317              :     pub const DEFAULT_EPHEMERAL_BYTES_PER_MEMORY_KB: usize = 0;
     318              : 
     319              :     pub const DEFAULT_IO_BUFFER_ALIGNMENT: usize = 512;
     320              : }
     321              : 
     322              : impl Default for ConfigToml {
     323          208 :     fn default() -> Self {
     324              :         use defaults::*;
     325              : 
     326          208 :         Self {
     327          208 :             listen_pg_addr: (DEFAULT_PG_LISTEN_ADDR.to_string()),
     328          208 :             listen_http_addr: (DEFAULT_HTTP_LISTEN_ADDR.to_string()),
     329          208 :             availability_zone: (None),
     330          208 :             wait_lsn_timeout: (humantime::parse_duration(DEFAULT_WAIT_LSN_TIMEOUT)
     331          208 :                 .expect("cannot parse default wait lsn timeout")),
     332          208 :             wal_redo_timeout: (humantime::parse_duration(DEFAULT_WAL_REDO_TIMEOUT)
     333          208 :                 .expect("cannot parse default wal redo timeout")),
     334          208 :             superuser: (DEFAULT_SUPERUSER.to_string()),
     335          208 :             locale: DEFAULT_LOCALE.to_string(),
     336          208 :             page_cache_size: (DEFAULT_PAGE_CACHE_SIZE),
     337          208 :             max_file_descriptors: (DEFAULT_MAX_FILE_DESCRIPTORS),
     338          208 :             pg_distrib_dir: None, // Utf8PathBuf::from("./pg_install"), // TODO: formely, this was std::env::current_dir()
     339          208 :             http_auth_type: (AuthType::Trust),
     340          208 :             pg_auth_type: (AuthType::Trust),
     341          208 :             auth_validation_public_key_path: (None),
     342          208 :             remote_storage: None,
     343          208 :             broker_endpoint: (storage_broker::DEFAULT_ENDPOINT
     344          208 :                 .parse()
     345          208 :                 .expect("failed to parse default broker endpoint")),
     346          208 :             broker_keepalive_interval: (humantime::parse_duration(
     347          208 :                 storage_broker::DEFAULT_KEEPALIVE_INTERVAL,
     348          208 :             )
     349          208 :             .expect("cannot parse default keepalive interval")),
     350          208 :             log_format: (LogFormat::from_str(DEFAULT_LOG_FORMAT).unwrap()),
     351          208 : 
     352          208 :             concurrent_tenant_warmup: (NonZeroUsize::new(DEFAULT_CONCURRENT_TENANT_WARMUP)
     353          208 :                 .expect("Invalid default constant")),
     354          208 :             concurrent_tenant_size_logical_size_queries: NonZeroUsize::new(
     355          208 :                 DEFAULT_CONCURRENT_TENANT_SIZE_LOGICAL_SIZE_QUERIES,
     356          208 :             )
     357          208 :             .unwrap(),
     358          208 :             metric_collection_interval: (humantime::parse_duration(
     359          208 :                 DEFAULT_METRIC_COLLECTION_INTERVAL,
     360          208 :             )
     361          208 :             .expect("cannot parse default metric collection interval")),
     362          208 :             synthetic_size_calculation_interval: (humantime::parse_duration(
     363          208 :                 DEFAULT_SYNTHETIC_SIZE_CALCULATION_INTERVAL,
     364          208 :             )
     365          208 :             .expect("cannot parse default synthetic size calculation interval")),
     366          208 :             metric_collection_endpoint: (DEFAULT_METRIC_COLLECTION_ENDPOINT),
     367          208 : 
     368          208 :             metric_collection_bucket: (None),
     369          208 : 
     370          208 :             disk_usage_based_eviction: (None),
     371          208 : 
     372          208 :             test_remote_failures: (0),
     373          208 : 
     374          208 :             ondemand_download_behavior_treat_error_as_warn: (false),
     375          208 : 
     376          208 :             background_task_maximum_delay: (humantime::parse_duration(
     377          208 :                 DEFAULT_BACKGROUND_TASK_MAXIMUM_DELAY,
     378          208 :             )
     379          208 :             .unwrap()),
     380          208 : 
     381          208 :             control_plane_api: (None),
     382          208 :             control_plane_api_token: (None),
     383          208 :             control_plane_emergency_mode: (false),
     384          208 : 
     385          208 :             heatmap_upload_concurrency: (DEFAULT_HEATMAP_UPLOAD_CONCURRENCY),
     386          208 :             secondary_download_concurrency: (DEFAULT_SECONDARY_DOWNLOAD_CONCURRENCY),
     387          208 : 
     388          208 :             ingest_batch_size: (DEFAULT_INGEST_BATCH_SIZE),
     389          208 : 
     390          208 :             virtual_file_io_engine: None,
     391          208 : 
     392          208 :             max_vectored_read_bytes: (MaxVectoredReadBytes(
     393          208 :                 NonZeroUsize::new(DEFAULT_MAX_VECTORED_READ_BYTES).unwrap(),
     394          208 :             )),
     395          208 :             image_compression: (DEFAULT_IMAGE_COMPRESSION),
     396          208 :             timeline_offloading: false,
     397          208 :             ephemeral_bytes_per_memory_kb: (DEFAULT_EPHEMERAL_BYTES_PER_MEMORY_KB),
     398          208 :             l0_flush: None,
     399          208 :             virtual_file_io_mode: None,
     400          208 :             tenant_config: TenantConfigToml::default(),
     401          208 :             no_sync: None,
     402          208 :         }
     403          208 :     }
     404              : }
     405              : 
     406              : pub mod tenant_conf_defaults {
     407              : 
     408              :     // FIXME: This current value is very low. I would imagine something like 1 GB or 10 GB
     409              :     // would be more appropriate. But a low value forces the code to be exercised more,
     410              :     // which is good for now to trigger bugs.
     411              :     // This parameter actually determines L0 layer file size.
     412              :     pub const DEFAULT_CHECKPOINT_DISTANCE: u64 = 256 * 1024 * 1024;
     413              :     pub const DEFAULT_CHECKPOINT_TIMEOUT: &str = "10 m";
     414              : 
     415              :     // FIXME the below configs are only used by legacy algorithm. The new algorithm
     416              :     // has different parameters.
     417              : 
     418              :     // Target file size, when creating image and delta layers.
     419              :     // This parameter determines L1 layer file size.
     420              :     pub const DEFAULT_COMPACTION_TARGET_SIZE: u64 = 128 * 1024 * 1024;
     421              : 
     422              :     pub const DEFAULT_COMPACTION_PERIOD: &str = "20 s";
     423              :     pub const DEFAULT_COMPACTION_THRESHOLD: usize = 10;
     424              :     pub const DEFAULT_COMPACTION_ALGORITHM: crate::models::CompactionAlgorithm =
     425              :         crate::models::CompactionAlgorithm::Legacy;
     426              : 
     427              :     pub const DEFAULT_GC_HORIZON: u64 = 64 * 1024 * 1024;
     428              : 
     429              :     // Large DEFAULT_GC_PERIOD is fine as long as PITR_INTERVAL is larger.
     430              :     // If there's a need to decrease this value, first make sure that GC
     431              :     // doesn't hold a layer map write lock for non-trivial operations.
     432              :     // Relevant: https://github.com/neondatabase/neon/issues/3394
     433              :     pub const DEFAULT_GC_PERIOD: &str = "1 hr";
     434              :     pub const DEFAULT_IMAGE_CREATION_THRESHOLD: usize = 3;
     435              :     pub const DEFAULT_PITR_INTERVAL: &str = "7 days";
     436              :     pub const DEFAULT_WALRECEIVER_CONNECT_TIMEOUT: &str = "10 seconds";
     437              :     pub const DEFAULT_WALRECEIVER_LAGGING_WAL_TIMEOUT: &str = "10 seconds";
     438              :     // The default limit on WAL lag should be set to avoid causing disconnects under high throughput
     439              :     // scenarios: since the broker stats are updated ~1/s, a value of 1GiB should be sufficient for
     440              :     // throughputs up to 1GiB/s per timeline.
     441              :     pub const DEFAULT_MAX_WALRECEIVER_LSN_WAL_LAG: u64 = 1024 * 1024 * 1024;
     442              :     pub const DEFAULT_EVICTIONS_LOW_RESIDENCE_DURATION_METRIC_THRESHOLD: &str = "24 hour";
     443              :     // By default ingest enough WAL for two new L0 layers before checking if new image
     444              :     // image layers should be created.
     445              :     pub const DEFAULT_IMAGE_LAYER_CREATION_CHECK_THRESHOLD: u8 = 2;
     446              : }
     447              : 
     448              : impl Default for TenantConfigToml {
     449          390 :     fn default() -> Self {
     450              :         use tenant_conf_defaults::*;
     451          390 :         Self {
     452          390 :             checkpoint_distance: DEFAULT_CHECKPOINT_DISTANCE,
     453          390 :             checkpoint_timeout: humantime::parse_duration(DEFAULT_CHECKPOINT_TIMEOUT)
     454          390 :                 .expect("cannot parse default checkpoint timeout"),
     455          390 :             compaction_target_size: DEFAULT_COMPACTION_TARGET_SIZE,
     456          390 :             compaction_period: humantime::parse_duration(DEFAULT_COMPACTION_PERIOD)
     457          390 :                 .expect("cannot parse default compaction period"),
     458          390 :             compaction_threshold: DEFAULT_COMPACTION_THRESHOLD,
     459          390 :             compaction_algorithm: crate::models::CompactionAlgorithmSettings {
     460          390 :                 kind: DEFAULT_COMPACTION_ALGORITHM,
     461          390 :             },
     462          390 :             gc_horizon: DEFAULT_GC_HORIZON,
     463          390 :             gc_period: humantime::parse_duration(DEFAULT_GC_PERIOD)
     464          390 :                 .expect("cannot parse default gc period"),
     465          390 :             image_creation_threshold: DEFAULT_IMAGE_CREATION_THRESHOLD,
     466          390 :             pitr_interval: humantime::parse_duration(DEFAULT_PITR_INTERVAL)
     467          390 :                 .expect("cannot parse default PITR interval"),
     468          390 :             walreceiver_connect_timeout: humantime::parse_duration(
     469          390 :                 DEFAULT_WALRECEIVER_CONNECT_TIMEOUT,
     470          390 :             )
     471          390 :             .expect("cannot parse default walreceiver connect timeout"),
     472          390 :             lagging_wal_timeout: humantime::parse_duration(DEFAULT_WALRECEIVER_LAGGING_WAL_TIMEOUT)
     473          390 :                 .expect("cannot parse default walreceiver lagging wal timeout"),
     474          390 :             max_lsn_wal_lag: NonZeroU64::new(DEFAULT_MAX_WALRECEIVER_LSN_WAL_LAG)
     475          390 :                 .expect("cannot parse default max walreceiver Lsn wal lag"),
     476          390 :             eviction_policy: crate::models::EvictionPolicy::NoEviction,
     477          390 :             min_resident_size_override: None,
     478          390 :             evictions_low_residence_duration_metric_threshold: humantime::parse_duration(
     479          390 :                 DEFAULT_EVICTIONS_LOW_RESIDENCE_DURATION_METRIC_THRESHOLD,
     480          390 :             )
     481          390 :             .expect("cannot parse default evictions_low_residence_duration_metric_threshold"),
     482          390 :             heatmap_period: Duration::ZERO,
     483          390 :             lazy_slru_download: false,
     484          390 :             timeline_get_throttle: crate::models::ThrottleConfig::disabled(),
     485          390 :             image_layer_creation_check_threshold: DEFAULT_IMAGE_LAYER_CREATION_CHECK_THRESHOLD,
     486          390 :             lsn_lease_length: LsnLease::DEFAULT_LENGTH,
     487          390 :             lsn_lease_length_for_ts: LsnLease::DEFAULT_LENGTH_FOR_TS,
     488          390 :             timeline_offloading: false,
     489          390 :         }
     490          390 :     }
     491              : }
        

Generated by: LCOV version 2.1-beta