LCOV - code coverage report
Current view: top level - libs/pageserver_api/src - config.rs (source / functions) Coverage Total Hit
Test: 7eb96e224e685167ad85f58f858387d8cf253f63.info Lines: 93.5 % 138 129
Test Date: 2024-09-23 21:23:07 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           66 : #[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              :     pub virtual_file_direct_io: crate::models::virtual_file::DirectIoMode,
     108              :     pub io_buffer_alignment: usize,
     109              : }
     110              : 
     111           12 : #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
     112              : #[serde(deny_unknown_fields)]
     113              : pub struct DiskUsageEvictionTaskConfig {
     114              :     pub max_usage_pct: utils::serde_percent::Percent,
     115              :     pub min_avail_bytes: u64,
     116              :     #[serde(with = "humantime_serde")]
     117              :     pub period: Duration,
     118              :     #[cfg(feature = "testing")]
     119              :     pub mock_statvfs: Option<statvfs::mock::Behavior>,
     120              :     /// Select sorting for evicted layers
     121              :     #[serde(default)]
     122              :     pub eviction_order: EvictionOrder,
     123              : }
     124              : 
     125              : pub mod statvfs {
     126              :     pub mod mock {
     127            0 :         #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
     128              :         #[serde(tag = "type")]
     129              :         pub enum Behavior {
     130              :             Success {
     131              :                 blocksize: u64,
     132              :                 total_blocks: u64,
     133              :                 name_filter: Option<utils::serde_regex::Regex>,
     134              :             },
     135              :             #[cfg(feature = "testing")]
     136              :             Failure { mocked_error: MockedError },
     137              :         }
     138              : 
     139              :         #[cfg(feature = "testing")]
     140            0 :         #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
     141              :         #[allow(clippy::upper_case_acronyms)]
     142              :         pub enum MockedError {
     143              :             EIO,
     144              :         }
     145              : 
     146              :         #[cfg(feature = "testing")]
     147              :         impl From<MockedError> for nix::Error {
     148            0 :             fn from(e: MockedError) -> Self {
     149            0 :                 match e {
     150            0 :                     MockedError::EIO => nix::Error::EIO,
     151            0 :                 }
     152            0 :             }
     153              :         }
     154              :     }
     155              : }
     156              : 
     157            0 : #[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
     158              : #[serde(tag = "type", content = "args")]
     159              : pub enum EvictionOrder {
     160              :     RelativeAccessed {
     161              :         highest_layer_count_loses_first: bool,
     162              :     },
     163              : }
     164              : 
     165              : impl Default for EvictionOrder {
     166            6 :     fn default() -> Self {
     167            6 :         Self::RelativeAccessed {
     168            6 :             highest_layer_count_loses_first: true,
     169            6 :         }
     170            6 :     }
     171              : }
     172              : 
     173            0 : #[derive(Copy, Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
     174              : #[serde(transparent)]
     175              : pub struct MaxVectoredReadBytes(pub NonZeroUsize);
     176              : 
     177              : /// A tenant's calcuated configuration, which is the result of merging a
     178              : /// tenant's TenantConfOpt with the global TenantConf from PageServerConf.
     179              : ///
     180              : /// For storing and transmitting individual tenant's configuration, see
     181              : /// TenantConfOpt.
     182           12 : #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
     183              : #[serde(deny_unknown_fields, default)]
     184              : pub struct TenantConfigToml {
     185              :     // Flush out an inmemory layer, if it's holding WAL older than this
     186              :     // This puts a backstop on how much WAL needs to be re-digested if the
     187              :     // page server crashes.
     188              :     // This parameter actually determines L0 layer file size.
     189              :     pub checkpoint_distance: u64,
     190              :     // Inmemory layer is also flushed at least once in checkpoint_timeout to
     191              :     // eventually upload WAL after activity is stopped.
     192              :     #[serde(with = "humantime_serde")]
     193              :     pub checkpoint_timeout: Duration,
     194              :     // Target file size, when creating image and delta layers.
     195              :     // This parameter determines L1 layer file size.
     196              :     pub compaction_target_size: u64,
     197              :     // How often to check if there's compaction work to be done.
     198              :     // Duration::ZERO means automatic compaction is disabled.
     199              :     #[serde(with = "humantime_serde")]
     200              :     pub compaction_period: Duration,
     201              :     // Level0 delta layer threshold for compaction.
     202              :     pub compaction_threshold: usize,
     203              :     pub compaction_algorithm: crate::models::CompactionAlgorithmSettings,
     204              :     // Determines how much history is retained, to allow
     205              :     // branching and read replicas at an older point in time.
     206              :     // The unit is #of bytes of WAL.
     207              :     // Page versions older than this are garbage collected away.
     208              :     pub gc_horizon: u64,
     209              :     // Interval at which garbage collection is triggered.
     210              :     // Duration::ZERO means automatic GC is disabled
     211              :     #[serde(with = "humantime_serde")]
     212              :     pub gc_period: Duration,
     213              :     // Delta layer churn threshold to create L1 image layers.
     214              :     pub image_creation_threshold: usize,
     215              :     // Determines how much history is retained, to allow
     216              :     // branching and read replicas at an older point in time.
     217              :     // The unit is time.
     218              :     // Page versions older than this are garbage collected away.
     219              :     #[serde(with = "humantime_serde")]
     220              :     pub pitr_interval: Duration,
     221              :     /// Maximum amount of time to wait while opening a connection to receive wal, before erroring.
     222              :     #[serde(with = "humantime_serde")]
     223              :     pub walreceiver_connect_timeout: Duration,
     224              :     /// Considers safekeepers stalled after no WAL updates were received longer than this threshold.
     225              :     /// A stalled safekeeper will be changed to a newer one when it appears.
     226              :     #[serde(with = "humantime_serde")]
     227              :     pub lagging_wal_timeout: Duration,
     228              :     /// Considers safekeepers lagging when their WAL is behind another safekeeper for more than this threshold.
     229              :     /// A lagging safekeeper will be changed after `lagging_wal_timeout` time elapses since the last WAL update,
     230              :     /// to avoid eager reconnects.
     231              :     pub max_lsn_wal_lag: NonZeroU64,
     232              :     pub eviction_policy: crate::models::EvictionPolicy,
     233              :     pub min_resident_size_override: Option<u64>,
     234              :     // See the corresponding metric's help string.
     235              :     #[serde(with = "humantime_serde")]
     236              :     pub evictions_low_residence_duration_metric_threshold: Duration,
     237              : 
     238              :     /// If non-zero, the period between uploads of a heatmap from attached tenants.  This
     239              :     /// may be disabled if a Tenant will not have secondary locations: only secondary
     240              :     /// locations will use the heatmap uploaded by attached locations.
     241              :     #[serde(with = "humantime_serde")]
     242              :     pub heatmap_period: Duration,
     243              : 
     244              :     /// If true then SLRU segments are dowloaded on demand, if false SLRU segments are included in basebackup
     245              :     pub lazy_slru_download: bool,
     246              : 
     247              :     pub timeline_get_throttle: crate::models::ThrottleConfig,
     248              : 
     249              :     // How much WAL must be ingested before checking again whether a new image layer is required.
     250              :     // Expresed in multiples of checkpoint distance.
     251              :     pub image_layer_creation_check_threshold: u8,
     252              : 
     253              :     /// Switch to a new aux file policy. Switching this flag requires the user has not written any aux file into
     254              :     /// the storage before, and this flag cannot be switched back. Otherwise there will be data corruptions.
     255              :     /// There is a `last_aux_file_policy` flag which gets persisted in `index_part.json` once the first aux
     256              :     /// file is written.
     257              :     pub switch_aux_file_policy: crate::models::AuxFilePolicy,
     258              : 
     259              :     /// The length for an explicit LSN lease request.
     260              :     /// Layers needed to reconstruct pages at LSN will not be GC-ed during this interval.
     261              :     #[serde(with = "humantime_serde")]
     262              :     pub lsn_lease_length: Duration,
     263              : 
     264              :     /// The length for an implicit LSN lease granted as part of `get_lsn_by_timestamp` request.
     265              :     /// Layers needed to reconstruct pages at LSN will not be GC-ed during this interval.
     266              :     #[serde(with = "humantime_serde")]
     267              :     pub lsn_lease_length_for_ts: Duration,
     268              : }
     269              : 
     270              : pub mod defaults {
     271              :     use crate::models::ImageCompressionAlgorithm;
     272              : 
     273              :     pub use storage_broker::DEFAULT_ENDPOINT as BROKER_DEFAULT_ENDPOINT;
     274              : 
     275              :     pub const DEFAULT_WAIT_LSN_TIMEOUT: &str = "300 s";
     276              :     pub const DEFAULT_WAL_REDO_TIMEOUT: &str = "60 s";
     277              : 
     278              :     pub const DEFAULT_SUPERUSER: &str = "cloud_admin";
     279              : 
     280              :     pub const DEFAULT_PAGE_CACHE_SIZE: usize = 8192;
     281              :     pub const DEFAULT_MAX_FILE_DESCRIPTORS: usize = 100;
     282              : 
     283              :     pub const DEFAULT_LOG_FORMAT: &str = "plain";
     284              : 
     285              :     pub const DEFAULT_CONCURRENT_TENANT_WARMUP: usize = 8;
     286              : 
     287              :     pub const DEFAULT_CONCURRENT_TENANT_SIZE_LOGICAL_SIZE_QUERIES: usize = 1;
     288              : 
     289              :     pub const DEFAULT_METRIC_COLLECTION_INTERVAL: &str = "10 min";
     290              :     pub const DEFAULT_METRIC_COLLECTION_ENDPOINT: Option<reqwest::Url> = None;
     291              :     pub const DEFAULT_SYNTHETIC_SIZE_CALCULATION_INTERVAL: &str = "10 min";
     292              :     pub const DEFAULT_BACKGROUND_TASK_MAXIMUM_DELAY: &str = "10s";
     293              : 
     294              :     pub const DEFAULT_HEATMAP_UPLOAD_CONCURRENCY: usize = 8;
     295              :     pub const DEFAULT_SECONDARY_DOWNLOAD_CONCURRENCY: usize = 1;
     296              : 
     297              :     pub const DEFAULT_INGEST_BATCH_SIZE: u64 = 100;
     298              : 
     299              :     pub const DEFAULT_MAX_VECTORED_READ_BYTES: usize = 128 * 1024; // 128 KiB
     300              : 
     301              :     pub const DEFAULT_IMAGE_COMPRESSION: ImageCompressionAlgorithm =
     302              :         ImageCompressionAlgorithm::Zstd { level: Some(1) };
     303              : 
     304              :     pub const DEFAULT_EPHEMERAL_BYTES_PER_MEMORY_KB: usize = 0;
     305              : 
     306              :     pub const DEFAULT_IO_BUFFER_ALIGNMENT: usize = 512;
     307              : }
     308              : 
     309              : impl Default for ConfigToml {
     310          624 :     fn default() -> Self {
     311              :         use defaults::*;
     312              : 
     313          624 :         Self {
     314          624 :             listen_pg_addr: (DEFAULT_PG_LISTEN_ADDR.to_string()),
     315          624 :             listen_http_addr: (DEFAULT_HTTP_LISTEN_ADDR.to_string()),
     316          624 :             availability_zone: (None),
     317          624 :             wait_lsn_timeout: (humantime::parse_duration(DEFAULT_WAIT_LSN_TIMEOUT)
     318          624 :                 .expect("cannot parse default wait lsn timeout")),
     319          624 :             wal_redo_timeout: (humantime::parse_duration(DEFAULT_WAL_REDO_TIMEOUT)
     320          624 :                 .expect("cannot parse default wal redo timeout")),
     321          624 :             superuser: (DEFAULT_SUPERUSER.to_string()),
     322          624 :             page_cache_size: (DEFAULT_PAGE_CACHE_SIZE),
     323          624 :             max_file_descriptors: (DEFAULT_MAX_FILE_DESCRIPTORS),
     324          624 :             pg_distrib_dir: None, // Utf8PathBuf::from("./pg_install"), // TODO: formely, this was std::env::current_dir()
     325          624 :             http_auth_type: (AuthType::Trust),
     326          624 :             pg_auth_type: (AuthType::Trust),
     327          624 :             auth_validation_public_key_path: (None),
     328          624 :             remote_storage: None,
     329          624 :             broker_endpoint: (storage_broker::DEFAULT_ENDPOINT
     330          624 :                 .parse()
     331          624 :                 .expect("failed to parse default broker endpoint")),
     332          624 :             broker_keepalive_interval: (humantime::parse_duration(
     333          624 :                 storage_broker::DEFAULT_KEEPALIVE_INTERVAL,
     334          624 :             )
     335          624 :             .expect("cannot parse default keepalive interval")),
     336          624 :             log_format: (LogFormat::from_str(DEFAULT_LOG_FORMAT).unwrap()),
     337          624 : 
     338          624 :             concurrent_tenant_warmup: (NonZeroUsize::new(DEFAULT_CONCURRENT_TENANT_WARMUP)
     339          624 :                 .expect("Invalid default constant")),
     340          624 :             concurrent_tenant_size_logical_size_queries: NonZeroUsize::new(
     341          624 :                 DEFAULT_CONCURRENT_TENANT_SIZE_LOGICAL_SIZE_QUERIES,
     342          624 :             )
     343          624 :             .unwrap(),
     344          624 :             metric_collection_interval: (humantime::parse_duration(
     345          624 :                 DEFAULT_METRIC_COLLECTION_INTERVAL,
     346          624 :             )
     347          624 :             .expect("cannot parse default metric collection interval")),
     348          624 :             synthetic_size_calculation_interval: (humantime::parse_duration(
     349          624 :                 DEFAULT_SYNTHETIC_SIZE_CALCULATION_INTERVAL,
     350          624 :             )
     351          624 :             .expect("cannot parse default synthetic size calculation interval")),
     352          624 :             metric_collection_endpoint: (DEFAULT_METRIC_COLLECTION_ENDPOINT),
     353          624 : 
     354          624 :             metric_collection_bucket: (None),
     355          624 : 
     356          624 :             disk_usage_based_eviction: (None),
     357          624 : 
     358          624 :             test_remote_failures: (0),
     359          624 : 
     360          624 :             ondemand_download_behavior_treat_error_as_warn: (false),
     361          624 : 
     362          624 :             background_task_maximum_delay: (humantime::parse_duration(
     363          624 :                 DEFAULT_BACKGROUND_TASK_MAXIMUM_DELAY,
     364          624 :             )
     365          624 :             .unwrap()),
     366          624 : 
     367          624 :             control_plane_api: (None),
     368          624 :             control_plane_api_token: (None),
     369          624 :             control_plane_emergency_mode: (false),
     370          624 : 
     371          624 :             heatmap_upload_concurrency: (DEFAULT_HEATMAP_UPLOAD_CONCURRENCY),
     372          624 :             secondary_download_concurrency: (DEFAULT_SECONDARY_DOWNLOAD_CONCURRENCY),
     373          624 : 
     374          624 :             ingest_batch_size: (DEFAULT_INGEST_BATCH_SIZE),
     375          624 : 
     376          624 :             virtual_file_io_engine: None,
     377          624 : 
     378          624 :             max_vectored_read_bytes: (MaxVectoredReadBytes(
     379          624 :                 NonZeroUsize::new(DEFAULT_MAX_VECTORED_READ_BYTES).unwrap(),
     380          624 :             )),
     381          624 :             image_compression: (DEFAULT_IMAGE_COMPRESSION),
     382          624 :             ephemeral_bytes_per_memory_kb: (DEFAULT_EPHEMERAL_BYTES_PER_MEMORY_KB),
     383          624 :             l0_flush: None,
     384          624 :             virtual_file_direct_io: crate::models::virtual_file::DirectIoMode::default(),
     385          624 : 
     386          624 :             io_buffer_alignment: DEFAULT_IO_BUFFER_ALIGNMENT,
     387          624 : 
     388          624 :             tenant_config: TenantConfigToml::default(),
     389          624 :         }
     390          624 :     }
     391              : }
     392              : 
     393              : pub mod tenant_conf_defaults {
     394              : 
     395              :     // FIXME: This current value is very low. I would imagine something like 1 GB or 10 GB
     396              :     // would be more appropriate. But a low value forces the code to be exercised more,
     397              :     // which is good for now to trigger bugs.
     398              :     // This parameter actually determines L0 layer file size.
     399              :     pub const DEFAULT_CHECKPOINT_DISTANCE: u64 = 256 * 1024 * 1024;
     400              :     pub const DEFAULT_CHECKPOINT_TIMEOUT: &str = "10 m";
     401              : 
     402              :     // FIXME the below configs are only used by legacy algorithm. The new algorithm
     403              :     // has different parameters.
     404              : 
     405              :     // Target file size, when creating image and delta layers.
     406              :     // This parameter determines L1 layer file size.
     407              :     pub const DEFAULT_COMPACTION_TARGET_SIZE: u64 = 128 * 1024 * 1024;
     408              : 
     409              :     pub const DEFAULT_COMPACTION_PERIOD: &str = "20 s";
     410              :     pub const DEFAULT_COMPACTION_THRESHOLD: usize = 10;
     411              :     pub const DEFAULT_COMPACTION_ALGORITHM: crate::models::CompactionAlgorithm =
     412              :         crate::models::CompactionAlgorithm::Legacy;
     413              : 
     414              :     pub const DEFAULT_GC_HORIZON: u64 = 64 * 1024 * 1024;
     415              : 
     416              :     // Large DEFAULT_GC_PERIOD is fine as long as PITR_INTERVAL is larger.
     417              :     // If there's a need to decrease this value, first make sure that GC
     418              :     // doesn't hold a layer map write lock for non-trivial operations.
     419              :     // Relevant: https://github.com/neondatabase/neon/issues/3394
     420              :     pub const DEFAULT_GC_PERIOD: &str = "1 hr";
     421              :     pub const DEFAULT_IMAGE_CREATION_THRESHOLD: usize = 3;
     422              :     pub const DEFAULT_PITR_INTERVAL: &str = "7 days";
     423              :     pub const DEFAULT_WALRECEIVER_CONNECT_TIMEOUT: &str = "10 seconds";
     424              :     pub const DEFAULT_WALRECEIVER_LAGGING_WAL_TIMEOUT: &str = "10 seconds";
     425              :     // The default limit on WAL lag should be set to avoid causing disconnects under high throughput
     426              :     // scenarios: since the broker stats are updated ~1/s, a value of 1GiB should be sufficient for
     427              :     // throughputs up to 1GiB/s per timeline.
     428              :     pub const DEFAULT_MAX_WALRECEIVER_LSN_WAL_LAG: u64 = 1024 * 1024 * 1024;
     429              :     pub const DEFAULT_EVICTIONS_LOW_RESIDENCE_DURATION_METRIC_THRESHOLD: &str = "24 hour";
     430              :     // By default ingest enough WAL for two new L0 layers before checking if new image
     431              :     // image layers should be created.
     432              :     pub const DEFAULT_IMAGE_LAYER_CREATION_CHECK_THRESHOLD: u8 = 2;
     433              : }
     434              : 
     435              : impl Default for TenantConfigToml {
     436         1170 :     fn default() -> Self {
     437              :         use tenant_conf_defaults::*;
     438         1170 :         Self {
     439         1170 :             checkpoint_distance: DEFAULT_CHECKPOINT_DISTANCE,
     440         1170 :             checkpoint_timeout: humantime::parse_duration(DEFAULT_CHECKPOINT_TIMEOUT)
     441         1170 :                 .expect("cannot parse default checkpoint timeout"),
     442         1170 :             compaction_target_size: DEFAULT_COMPACTION_TARGET_SIZE,
     443         1170 :             compaction_period: humantime::parse_duration(DEFAULT_COMPACTION_PERIOD)
     444         1170 :                 .expect("cannot parse default compaction period"),
     445         1170 :             compaction_threshold: DEFAULT_COMPACTION_THRESHOLD,
     446         1170 :             compaction_algorithm: crate::models::CompactionAlgorithmSettings {
     447         1170 :                 kind: DEFAULT_COMPACTION_ALGORITHM,
     448         1170 :             },
     449         1170 :             gc_horizon: DEFAULT_GC_HORIZON,
     450         1170 :             gc_period: humantime::parse_duration(DEFAULT_GC_PERIOD)
     451         1170 :                 .expect("cannot parse default gc period"),
     452         1170 :             image_creation_threshold: DEFAULT_IMAGE_CREATION_THRESHOLD,
     453         1170 :             pitr_interval: humantime::parse_duration(DEFAULT_PITR_INTERVAL)
     454         1170 :                 .expect("cannot parse default PITR interval"),
     455         1170 :             walreceiver_connect_timeout: humantime::parse_duration(
     456         1170 :                 DEFAULT_WALRECEIVER_CONNECT_TIMEOUT,
     457         1170 :             )
     458         1170 :             .expect("cannot parse default walreceiver connect timeout"),
     459         1170 :             lagging_wal_timeout: humantime::parse_duration(DEFAULT_WALRECEIVER_LAGGING_WAL_TIMEOUT)
     460         1170 :                 .expect("cannot parse default walreceiver lagging wal timeout"),
     461         1170 :             max_lsn_wal_lag: NonZeroU64::new(DEFAULT_MAX_WALRECEIVER_LSN_WAL_LAG)
     462         1170 :                 .expect("cannot parse default max walreceiver Lsn wal lag"),
     463         1170 :             eviction_policy: crate::models::EvictionPolicy::NoEviction,
     464         1170 :             min_resident_size_override: None,
     465         1170 :             evictions_low_residence_duration_metric_threshold: humantime::parse_duration(
     466         1170 :                 DEFAULT_EVICTIONS_LOW_RESIDENCE_DURATION_METRIC_THRESHOLD,
     467         1170 :             )
     468         1170 :             .expect("cannot parse default evictions_low_residence_duration_metric_threshold"),
     469         1170 :             heatmap_period: Duration::ZERO,
     470         1170 :             lazy_slru_download: false,
     471         1170 :             timeline_get_throttle: crate::models::ThrottleConfig::disabled(),
     472         1170 :             image_layer_creation_check_threshold: DEFAULT_IMAGE_LAYER_CREATION_CHECK_THRESHOLD,
     473         1170 :             switch_aux_file_policy: crate::models::AuxFilePolicy::default_tenant_config(),
     474         1170 :             lsn_lease_length: LsnLease::DEFAULT_LENGTH,
     475         1170 :             lsn_lease_length_for_ts: LsnLease::DEFAULT_LENGTH_FOR_TS,
     476         1170 :         }
     477         1170 :     }
     478              : }
        

Generated by: LCOV version 2.1-beta