LCOV - code coverage report
Current view: top level - libs/pageserver_api/src - config.rs (source / functions) Coverage Total Hit
Test: 90b23405d17e36048d3bb64e314067f397803f1b.info Lines: 93.5 % 139 130
Test Date: 2024-09-20 13:14:58 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           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            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           12 : #[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              :     /// Switch to a new aux file policy. Switching this flag requires the user has not written any aux file into
     257              :     /// the storage before, and this flag cannot be switched back. Otherwise there will be data corruptions.
     258              :     /// There is a `last_aux_file_policy` flag which gets persisted in `index_part.json` once the first aux
     259              :     /// file is written.
     260              :     pub switch_aux_file_policy: crate::models::AuxFilePolicy,
     261              : 
     262              :     /// The length for an explicit LSN lease request.
     263              :     /// Layers needed to reconstruct pages at LSN will not be GC-ed during this interval.
     264              :     #[serde(with = "humantime_serde")]
     265              :     pub lsn_lease_length: Duration,
     266              : 
     267              :     /// The length for an implicit LSN lease granted as part of `get_lsn_by_timestamp` request.
     268              :     /// Layers needed to reconstruct pages at LSN will not be GC-ed during this interval.
     269              :     #[serde(with = "humantime_serde")]
     270              :     pub lsn_lease_length_for_ts: Duration,
     271              : }
     272              : 
     273              : pub mod defaults {
     274              :     use crate::models::ImageCompressionAlgorithm;
     275              : 
     276              :     pub use storage_broker::DEFAULT_ENDPOINT as BROKER_DEFAULT_ENDPOINT;
     277              : 
     278              :     pub const DEFAULT_WAIT_LSN_TIMEOUT: &str = "300 s";
     279              :     pub const DEFAULT_WAL_REDO_TIMEOUT: &str = "60 s";
     280              : 
     281              :     pub const DEFAULT_SUPERUSER: &str = "cloud_admin";
     282              : 
     283              :     pub const DEFAULT_PAGE_CACHE_SIZE: usize = 8192;
     284              :     pub const DEFAULT_MAX_FILE_DESCRIPTORS: usize = 100;
     285              : 
     286              :     pub const DEFAULT_LOG_FORMAT: &str = "plain";
     287              : 
     288              :     pub const DEFAULT_CONCURRENT_TENANT_WARMUP: usize = 8;
     289              : 
     290              :     pub const DEFAULT_CONCURRENT_TENANT_SIZE_LOGICAL_SIZE_QUERIES: usize = 1;
     291              : 
     292              :     pub const DEFAULT_METRIC_COLLECTION_INTERVAL: &str = "10 min";
     293              :     pub const DEFAULT_METRIC_COLLECTION_ENDPOINT: Option<reqwest::Url> = None;
     294              :     pub const DEFAULT_SYNTHETIC_SIZE_CALCULATION_INTERVAL: &str = "10 min";
     295              :     pub const DEFAULT_BACKGROUND_TASK_MAXIMUM_DELAY: &str = "10s";
     296              : 
     297              :     pub const DEFAULT_HEATMAP_UPLOAD_CONCURRENCY: usize = 8;
     298              :     pub const DEFAULT_SECONDARY_DOWNLOAD_CONCURRENCY: usize = 1;
     299              : 
     300              :     pub const DEFAULT_INGEST_BATCH_SIZE: u64 = 100;
     301              : 
     302              :     pub const DEFAULT_MAX_VECTORED_READ_BYTES: usize = 128 * 1024; // 128 KiB
     303              : 
     304              :     pub const DEFAULT_IMAGE_COMPRESSION: ImageCompressionAlgorithm =
     305              :         ImageCompressionAlgorithm::Zstd { level: Some(1) };
     306              : 
     307              :     pub const DEFAULT_EPHEMERAL_BYTES_PER_MEMORY_KB: usize = 0;
     308              : 
     309              :     pub const DEFAULT_IO_BUFFER_ALIGNMENT: usize = 512;
     310              : }
     311              : 
     312              : impl Default for ConfigToml {
     313          624 :     fn default() -> Self {
     314              :         use defaults::*;
     315              : 
     316          624 :         Self {
     317          624 :             listen_pg_addr: (DEFAULT_PG_LISTEN_ADDR.to_string()),
     318          624 :             listen_http_addr: (DEFAULT_HTTP_LISTEN_ADDR.to_string()),
     319          624 :             availability_zone: (None),
     320          624 :             wait_lsn_timeout: (humantime::parse_duration(DEFAULT_WAIT_LSN_TIMEOUT)
     321          624 :                 .expect("cannot parse default wait lsn timeout")),
     322          624 :             wal_redo_timeout: (humantime::parse_duration(DEFAULT_WAL_REDO_TIMEOUT)
     323          624 :                 .expect("cannot parse default wal redo timeout")),
     324          624 :             superuser: (DEFAULT_SUPERUSER.to_string()),
     325          624 :             page_cache_size: (DEFAULT_PAGE_CACHE_SIZE),
     326          624 :             max_file_descriptors: (DEFAULT_MAX_FILE_DESCRIPTORS),
     327          624 :             pg_distrib_dir: None, // Utf8PathBuf::from("./pg_install"), // TODO: formely, this was std::env::current_dir()
     328          624 :             http_auth_type: (AuthType::Trust),
     329          624 :             pg_auth_type: (AuthType::Trust),
     330          624 :             auth_validation_public_key_path: (None),
     331          624 :             remote_storage: None,
     332          624 :             broker_endpoint: (storage_broker::DEFAULT_ENDPOINT
     333          624 :                 .parse()
     334          624 :                 .expect("failed to parse default broker endpoint")),
     335          624 :             broker_keepalive_interval: (humantime::parse_duration(
     336          624 :                 storage_broker::DEFAULT_KEEPALIVE_INTERVAL,
     337          624 :             )
     338          624 :             .expect("cannot parse default keepalive interval")),
     339          624 :             log_format: (LogFormat::from_str(DEFAULT_LOG_FORMAT).unwrap()),
     340          624 : 
     341          624 :             concurrent_tenant_warmup: (NonZeroUsize::new(DEFAULT_CONCURRENT_TENANT_WARMUP)
     342          624 :                 .expect("Invalid default constant")),
     343          624 :             concurrent_tenant_size_logical_size_queries: NonZeroUsize::new(
     344          624 :                 DEFAULT_CONCURRENT_TENANT_SIZE_LOGICAL_SIZE_QUERIES,
     345          624 :             )
     346          624 :             .unwrap(),
     347          624 :             metric_collection_interval: (humantime::parse_duration(
     348          624 :                 DEFAULT_METRIC_COLLECTION_INTERVAL,
     349          624 :             )
     350          624 :             .expect("cannot parse default metric collection interval")),
     351          624 :             synthetic_size_calculation_interval: (humantime::parse_duration(
     352          624 :                 DEFAULT_SYNTHETIC_SIZE_CALCULATION_INTERVAL,
     353          624 :             )
     354          624 :             .expect("cannot parse default synthetic size calculation interval")),
     355          624 :             metric_collection_endpoint: (DEFAULT_METRIC_COLLECTION_ENDPOINT),
     356          624 : 
     357          624 :             metric_collection_bucket: (None),
     358          624 : 
     359          624 :             disk_usage_based_eviction: (None),
     360          624 : 
     361          624 :             test_remote_failures: (0),
     362          624 : 
     363          624 :             ondemand_download_behavior_treat_error_as_warn: (false),
     364          624 : 
     365          624 :             background_task_maximum_delay: (humantime::parse_duration(
     366          624 :                 DEFAULT_BACKGROUND_TASK_MAXIMUM_DELAY,
     367          624 :             )
     368          624 :             .unwrap()),
     369          624 : 
     370          624 :             control_plane_api: (None),
     371          624 :             control_plane_api_token: (None),
     372          624 :             control_plane_emergency_mode: (false),
     373          624 : 
     374          624 :             heatmap_upload_concurrency: (DEFAULT_HEATMAP_UPLOAD_CONCURRENCY),
     375          624 :             secondary_download_concurrency: (DEFAULT_SECONDARY_DOWNLOAD_CONCURRENCY),
     376          624 : 
     377          624 :             ingest_batch_size: (DEFAULT_INGEST_BATCH_SIZE),
     378          624 : 
     379          624 :             virtual_file_io_engine: None,
     380          624 : 
     381          624 :             max_vectored_read_bytes: (MaxVectoredReadBytes(
     382          624 :                 NonZeroUsize::new(DEFAULT_MAX_VECTORED_READ_BYTES).unwrap(),
     383          624 :             )),
     384          624 :             image_compression: (DEFAULT_IMAGE_COMPRESSION),
     385          624 :             ephemeral_bytes_per_memory_kb: (DEFAULT_EPHEMERAL_BYTES_PER_MEMORY_KB),
     386          624 :             l0_flush: None,
     387          624 :             compact_level0_phase1_value_access: Default::default(),
     388          624 :             virtual_file_direct_io: crate::models::virtual_file::DirectIoMode::default(),
     389          624 : 
     390          624 :             io_buffer_alignment: DEFAULT_IO_BUFFER_ALIGNMENT,
     391          624 : 
     392          624 :             tenant_config: TenantConfigToml::default(),
     393          624 :         }
     394          624 :     }
     395              : }
     396              : 
     397              : pub mod tenant_conf_defaults {
     398              : 
     399              :     // FIXME: This current value is very low. I would imagine something like 1 GB or 10 GB
     400              :     // would be more appropriate. But a low value forces the code to be exercised more,
     401              :     // which is good for now to trigger bugs.
     402              :     // This parameter actually determines L0 layer file size.
     403              :     pub const DEFAULT_CHECKPOINT_DISTANCE: u64 = 256 * 1024 * 1024;
     404              :     pub const DEFAULT_CHECKPOINT_TIMEOUT: &str = "10 m";
     405              : 
     406              :     // FIXME the below configs are only used by legacy algorithm. The new algorithm
     407              :     // has different parameters.
     408              : 
     409              :     // Target file size, when creating image and delta layers.
     410              :     // This parameter determines L1 layer file size.
     411              :     pub const DEFAULT_COMPACTION_TARGET_SIZE: u64 = 128 * 1024 * 1024;
     412              : 
     413              :     pub const DEFAULT_COMPACTION_PERIOD: &str = "20 s";
     414              :     pub const DEFAULT_COMPACTION_THRESHOLD: usize = 10;
     415              :     pub const DEFAULT_COMPACTION_ALGORITHM: crate::models::CompactionAlgorithm =
     416              :         crate::models::CompactionAlgorithm::Legacy;
     417              : 
     418              :     pub const DEFAULT_GC_HORIZON: u64 = 64 * 1024 * 1024;
     419              : 
     420              :     // Large DEFAULT_GC_PERIOD is fine as long as PITR_INTERVAL is larger.
     421              :     // If there's a need to decrease this value, first make sure that GC
     422              :     // doesn't hold a layer map write lock for non-trivial operations.
     423              :     // Relevant: https://github.com/neondatabase/neon/issues/3394
     424              :     pub const DEFAULT_GC_PERIOD: &str = "1 hr";
     425              :     pub const DEFAULT_IMAGE_CREATION_THRESHOLD: usize = 3;
     426              :     pub const DEFAULT_PITR_INTERVAL: &str = "7 days";
     427              :     pub const DEFAULT_WALRECEIVER_CONNECT_TIMEOUT: &str = "10 seconds";
     428              :     pub const DEFAULT_WALRECEIVER_LAGGING_WAL_TIMEOUT: &str = "10 seconds";
     429              :     // The default limit on WAL lag should be set to avoid causing disconnects under high throughput
     430              :     // scenarios: since the broker stats are updated ~1/s, a value of 1GiB should be sufficient for
     431              :     // throughputs up to 1GiB/s per timeline.
     432              :     pub const DEFAULT_MAX_WALRECEIVER_LSN_WAL_LAG: u64 = 1024 * 1024 * 1024;
     433              :     pub const DEFAULT_EVICTIONS_LOW_RESIDENCE_DURATION_METRIC_THRESHOLD: &str = "24 hour";
     434              :     // By default ingest enough WAL for two new L0 layers before checking if new image
     435              :     // image layers should be created.
     436              :     pub const DEFAULT_IMAGE_LAYER_CREATION_CHECK_THRESHOLD: u8 = 2;
     437              : }
     438              : 
     439              : impl Default for TenantConfigToml {
     440         1170 :     fn default() -> Self {
     441              :         use tenant_conf_defaults::*;
     442         1170 :         Self {
     443         1170 :             checkpoint_distance: DEFAULT_CHECKPOINT_DISTANCE,
     444         1170 :             checkpoint_timeout: humantime::parse_duration(DEFAULT_CHECKPOINT_TIMEOUT)
     445         1170 :                 .expect("cannot parse default checkpoint timeout"),
     446         1170 :             compaction_target_size: DEFAULT_COMPACTION_TARGET_SIZE,
     447         1170 :             compaction_period: humantime::parse_duration(DEFAULT_COMPACTION_PERIOD)
     448         1170 :                 .expect("cannot parse default compaction period"),
     449         1170 :             compaction_threshold: DEFAULT_COMPACTION_THRESHOLD,
     450         1170 :             compaction_algorithm: crate::models::CompactionAlgorithmSettings {
     451         1170 :                 kind: DEFAULT_COMPACTION_ALGORITHM,
     452         1170 :             },
     453         1170 :             gc_horizon: DEFAULT_GC_HORIZON,
     454         1170 :             gc_period: humantime::parse_duration(DEFAULT_GC_PERIOD)
     455         1170 :                 .expect("cannot parse default gc period"),
     456         1170 :             image_creation_threshold: DEFAULT_IMAGE_CREATION_THRESHOLD,
     457         1170 :             pitr_interval: humantime::parse_duration(DEFAULT_PITR_INTERVAL)
     458         1170 :                 .expect("cannot parse default PITR interval"),
     459         1170 :             walreceiver_connect_timeout: humantime::parse_duration(
     460         1170 :                 DEFAULT_WALRECEIVER_CONNECT_TIMEOUT,
     461         1170 :             )
     462         1170 :             .expect("cannot parse default walreceiver connect timeout"),
     463         1170 :             lagging_wal_timeout: humantime::parse_duration(DEFAULT_WALRECEIVER_LAGGING_WAL_TIMEOUT)
     464         1170 :                 .expect("cannot parse default walreceiver lagging wal timeout"),
     465         1170 :             max_lsn_wal_lag: NonZeroU64::new(DEFAULT_MAX_WALRECEIVER_LSN_WAL_LAG)
     466         1170 :                 .expect("cannot parse default max walreceiver Lsn wal lag"),
     467         1170 :             eviction_policy: crate::models::EvictionPolicy::NoEviction,
     468         1170 :             min_resident_size_override: None,
     469         1170 :             evictions_low_residence_duration_metric_threshold: humantime::parse_duration(
     470         1170 :                 DEFAULT_EVICTIONS_LOW_RESIDENCE_DURATION_METRIC_THRESHOLD,
     471         1170 :             )
     472         1170 :             .expect("cannot parse default evictions_low_residence_duration_metric_threshold"),
     473         1170 :             heatmap_period: Duration::ZERO,
     474         1170 :             lazy_slru_download: false,
     475         1170 :             timeline_get_throttle: crate::models::ThrottleConfig::disabled(),
     476         1170 :             image_layer_creation_check_threshold: DEFAULT_IMAGE_LAYER_CREATION_CHECK_THRESHOLD,
     477         1170 :             switch_aux_file_policy: crate::models::AuxFilePolicy::default_tenant_config(),
     478         1170 :             lsn_lease_length: LsnLease::DEFAULT_LENGTH,
     479         1170 :             lsn_lease_length_for_ts: LsnLease::DEFAULT_LENGTH_FOR_TS,
     480         1170 :         }
     481         1170 :     }
     482              : }
        

Generated by: LCOV version 2.1-beta