LCOV - code coverage report
Current view: top level - libs/pageserver_api/src - config.rs (source / functions) Coverage Total Hit
Test: b4ae4c4857f9ef3e144e982a35ee23bc84c71983.info Lines: 93.4 % 136 127
Test Date: 2024-10-22 22:13:45 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 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 timeline_offloading: bool,
     106              :     pub ephemeral_bytes_per_memory_kb: usize,
     107              :     pub l0_flush: Option<crate::models::L0FlushConfig>,
     108              :     pub virtual_file_io_mode: Option<crate::models::virtual_file::IoMode>,
     109              : }
     110              : 
     111            4 : #[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            2 :     fn default() -> Self {
     167            2 :         Self::RelativeAccessed {
     168            2 :             highest_layer_count_loses_first: true,
     169            2 :         }
     170            2 :     }
     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            4 : #[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              :     /// Soft limit for the maximum size of a vectored read.
     300              :     ///
     301              :     /// This is determined by the largest NeonWalRecord that can exist (minus dbdir and reldir keys
     302              :     /// which are bounded by the blob io limits only). As of this writing, that is a `NeonWalRecord::ClogSetCommitted` record,
     303              :     /// with 32k xids. That's the max number of XIDS on a single CLOG page. The size of such a record
     304              :     /// is `sizeof(Transactionid) * 32768 + (some fixed overhead from 'timestamp`, the Vec length and whatever extra serde serialization adds)`.
     305              :     /// That is, slightly above 128 kB.
     306              :     pub const DEFAULT_MAX_VECTORED_READ_BYTES: usize = 130 * 1024; // 130 KiB
     307              : 
     308              :     pub const DEFAULT_IMAGE_COMPRESSION: ImageCompressionAlgorithm =
     309              :         ImageCompressionAlgorithm::Zstd { level: Some(1) };
     310              : 
     311              :     pub const DEFAULT_EPHEMERAL_BYTES_PER_MEMORY_KB: usize = 0;
     312              : 
     313              :     pub const DEFAULT_IO_BUFFER_ALIGNMENT: usize = 512;
     314              : }
     315              : 
     316              : impl Default for ConfigToml {
     317          204 :     fn default() -> Self {
     318              :         use defaults::*;
     319              : 
     320          204 :         Self {
     321          204 :             listen_pg_addr: (DEFAULT_PG_LISTEN_ADDR.to_string()),
     322          204 :             listen_http_addr: (DEFAULT_HTTP_LISTEN_ADDR.to_string()),
     323          204 :             availability_zone: (None),
     324          204 :             wait_lsn_timeout: (humantime::parse_duration(DEFAULT_WAIT_LSN_TIMEOUT)
     325          204 :                 .expect("cannot parse default wait lsn timeout")),
     326          204 :             wal_redo_timeout: (humantime::parse_duration(DEFAULT_WAL_REDO_TIMEOUT)
     327          204 :                 .expect("cannot parse default wal redo timeout")),
     328          204 :             superuser: (DEFAULT_SUPERUSER.to_string()),
     329          204 :             page_cache_size: (DEFAULT_PAGE_CACHE_SIZE),
     330          204 :             max_file_descriptors: (DEFAULT_MAX_FILE_DESCRIPTORS),
     331          204 :             pg_distrib_dir: None, // Utf8PathBuf::from("./pg_install"), // TODO: formely, this was std::env::current_dir()
     332          204 :             http_auth_type: (AuthType::Trust),
     333          204 :             pg_auth_type: (AuthType::Trust),
     334          204 :             auth_validation_public_key_path: (None),
     335          204 :             remote_storage: None,
     336          204 :             broker_endpoint: (storage_broker::DEFAULT_ENDPOINT
     337          204 :                 .parse()
     338          204 :                 .expect("failed to parse default broker endpoint")),
     339          204 :             broker_keepalive_interval: (humantime::parse_duration(
     340          204 :                 storage_broker::DEFAULT_KEEPALIVE_INTERVAL,
     341          204 :             )
     342          204 :             .expect("cannot parse default keepalive interval")),
     343          204 :             log_format: (LogFormat::from_str(DEFAULT_LOG_FORMAT).unwrap()),
     344          204 : 
     345          204 :             concurrent_tenant_warmup: (NonZeroUsize::new(DEFAULT_CONCURRENT_TENANT_WARMUP)
     346          204 :                 .expect("Invalid default constant")),
     347          204 :             concurrent_tenant_size_logical_size_queries: NonZeroUsize::new(
     348          204 :                 DEFAULT_CONCURRENT_TENANT_SIZE_LOGICAL_SIZE_QUERIES,
     349          204 :             )
     350          204 :             .unwrap(),
     351          204 :             metric_collection_interval: (humantime::parse_duration(
     352          204 :                 DEFAULT_METRIC_COLLECTION_INTERVAL,
     353          204 :             )
     354          204 :             .expect("cannot parse default metric collection interval")),
     355          204 :             synthetic_size_calculation_interval: (humantime::parse_duration(
     356          204 :                 DEFAULT_SYNTHETIC_SIZE_CALCULATION_INTERVAL,
     357          204 :             )
     358          204 :             .expect("cannot parse default synthetic size calculation interval")),
     359          204 :             metric_collection_endpoint: (DEFAULT_METRIC_COLLECTION_ENDPOINT),
     360          204 : 
     361          204 :             metric_collection_bucket: (None),
     362          204 : 
     363          204 :             disk_usage_based_eviction: (None),
     364          204 : 
     365          204 :             test_remote_failures: (0),
     366          204 : 
     367          204 :             ondemand_download_behavior_treat_error_as_warn: (false),
     368          204 : 
     369          204 :             background_task_maximum_delay: (humantime::parse_duration(
     370          204 :                 DEFAULT_BACKGROUND_TASK_MAXIMUM_DELAY,
     371          204 :             )
     372          204 :             .unwrap()),
     373          204 : 
     374          204 :             control_plane_api: (None),
     375          204 :             control_plane_api_token: (None),
     376          204 :             control_plane_emergency_mode: (false),
     377          204 : 
     378          204 :             heatmap_upload_concurrency: (DEFAULT_HEATMAP_UPLOAD_CONCURRENCY),
     379          204 :             secondary_download_concurrency: (DEFAULT_SECONDARY_DOWNLOAD_CONCURRENCY),
     380          204 : 
     381          204 :             ingest_batch_size: (DEFAULT_INGEST_BATCH_SIZE),
     382          204 : 
     383          204 :             virtual_file_io_engine: None,
     384          204 : 
     385          204 :             max_vectored_read_bytes: (MaxVectoredReadBytes(
     386          204 :                 NonZeroUsize::new(DEFAULT_MAX_VECTORED_READ_BYTES).unwrap(),
     387          204 :             )),
     388          204 :             image_compression: (DEFAULT_IMAGE_COMPRESSION),
     389          204 :             timeline_offloading: false,
     390          204 :             ephemeral_bytes_per_memory_kb: (DEFAULT_EPHEMERAL_BYTES_PER_MEMORY_KB),
     391          204 :             l0_flush: None,
     392          204 :             virtual_file_io_mode: None,
     393          204 :             tenant_config: TenantConfigToml::default(),
     394          204 :         }
     395          204 :     }
     396              : }
     397              : 
     398              : pub mod tenant_conf_defaults {
     399              : 
     400              :     // FIXME: This current value is very low. I would imagine something like 1 GB or 10 GB
     401              :     // would be more appropriate. But a low value forces the code to be exercised more,
     402              :     // which is good for now to trigger bugs.
     403              :     // This parameter actually determines L0 layer file size.
     404              :     pub const DEFAULT_CHECKPOINT_DISTANCE: u64 = 256 * 1024 * 1024;
     405              :     pub const DEFAULT_CHECKPOINT_TIMEOUT: &str = "10 m";
     406              : 
     407              :     // FIXME the below configs are only used by legacy algorithm. The new algorithm
     408              :     // has different parameters.
     409              : 
     410              :     // Target file size, when creating image and delta layers.
     411              :     // This parameter determines L1 layer file size.
     412              :     pub const DEFAULT_COMPACTION_TARGET_SIZE: u64 = 128 * 1024 * 1024;
     413              : 
     414              :     pub const DEFAULT_COMPACTION_PERIOD: &str = "20 s";
     415              :     pub const DEFAULT_COMPACTION_THRESHOLD: usize = 10;
     416              :     pub const DEFAULT_COMPACTION_ALGORITHM: crate::models::CompactionAlgorithm =
     417              :         crate::models::CompactionAlgorithm::Legacy;
     418              : 
     419              :     pub const DEFAULT_GC_HORIZON: u64 = 64 * 1024 * 1024;
     420              : 
     421              :     // Large DEFAULT_GC_PERIOD is fine as long as PITR_INTERVAL is larger.
     422              :     // If there's a need to decrease this value, first make sure that GC
     423              :     // doesn't hold a layer map write lock for non-trivial operations.
     424              :     // Relevant: https://github.com/neondatabase/neon/issues/3394
     425              :     pub const DEFAULT_GC_PERIOD: &str = "1 hr";
     426              :     pub const DEFAULT_IMAGE_CREATION_THRESHOLD: usize = 3;
     427              :     pub const DEFAULT_PITR_INTERVAL: &str = "7 days";
     428              :     pub const DEFAULT_WALRECEIVER_CONNECT_TIMEOUT: &str = "10 seconds";
     429              :     pub const DEFAULT_WALRECEIVER_LAGGING_WAL_TIMEOUT: &str = "10 seconds";
     430              :     // The default limit on WAL lag should be set to avoid causing disconnects under high throughput
     431              :     // scenarios: since the broker stats are updated ~1/s, a value of 1GiB should be sufficient for
     432              :     // throughputs up to 1GiB/s per timeline.
     433              :     pub const DEFAULT_MAX_WALRECEIVER_LSN_WAL_LAG: u64 = 1024 * 1024 * 1024;
     434              :     pub const DEFAULT_EVICTIONS_LOW_RESIDENCE_DURATION_METRIC_THRESHOLD: &str = "24 hour";
     435              :     // By default ingest enough WAL for two new L0 layers before checking if new image
     436              :     // image layers should be created.
     437              :     pub const DEFAULT_IMAGE_LAYER_CREATION_CHECK_THRESHOLD: u8 = 2;
     438              : }
     439              : 
     440              : impl Default for TenantConfigToml {
     441          382 :     fn default() -> Self {
     442              :         use tenant_conf_defaults::*;
     443          382 :         Self {
     444          382 :             checkpoint_distance: DEFAULT_CHECKPOINT_DISTANCE,
     445          382 :             checkpoint_timeout: humantime::parse_duration(DEFAULT_CHECKPOINT_TIMEOUT)
     446          382 :                 .expect("cannot parse default checkpoint timeout"),
     447          382 :             compaction_target_size: DEFAULT_COMPACTION_TARGET_SIZE,
     448          382 :             compaction_period: humantime::parse_duration(DEFAULT_COMPACTION_PERIOD)
     449          382 :                 .expect("cannot parse default compaction period"),
     450          382 :             compaction_threshold: DEFAULT_COMPACTION_THRESHOLD,
     451          382 :             compaction_algorithm: crate::models::CompactionAlgorithmSettings {
     452          382 :                 kind: DEFAULT_COMPACTION_ALGORITHM,
     453          382 :             },
     454          382 :             gc_horizon: DEFAULT_GC_HORIZON,
     455          382 :             gc_period: humantime::parse_duration(DEFAULT_GC_PERIOD)
     456          382 :                 .expect("cannot parse default gc period"),
     457          382 :             image_creation_threshold: DEFAULT_IMAGE_CREATION_THRESHOLD,
     458          382 :             pitr_interval: humantime::parse_duration(DEFAULT_PITR_INTERVAL)
     459          382 :                 .expect("cannot parse default PITR interval"),
     460          382 :             walreceiver_connect_timeout: humantime::parse_duration(
     461          382 :                 DEFAULT_WALRECEIVER_CONNECT_TIMEOUT,
     462          382 :             )
     463          382 :             .expect("cannot parse default walreceiver connect timeout"),
     464          382 :             lagging_wal_timeout: humantime::parse_duration(DEFAULT_WALRECEIVER_LAGGING_WAL_TIMEOUT)
     465          382 :                 .expect("cannot parse default walreceiver lagging wal timeout"),
     466          382 :             max_lsn_wal_lag: NonZeroU64::new(DEFAULT_MAX_WALRECEIVER_LSN_WAL_LAG)
     467          382 :                 .expect("cannot parse default max walreceiver Lsn wal lag"),
     468          382 :             eviction_policy: crate::models::EvictionPolicy::NoEviction,
     469          382 :             min_resident_size_override: None,
     470          382 :             evictions_low_residence_duration_metric_threshold: humantime::parse_duration(
     471          382 :                 DEFAULT_EVICTIONS_LOW_RESIDENCE_DURATION_METRIC_THRESHOLD,
     472          382 :             )
     473          382 :             .expect("cannot parse default evictions_low_residence_duration_metric_threshold"),
     474          382 :             heatmap_period: Duration::ZERO,
     475          382 :             lazy_slru_download: false,
     476          382 :             timeline_get_throttle: crate::models::ThrottleConfig::disabled(),
     477          382 :             image_layer_creation_check_threshold: DEFAULT_IMAGE_LAYER_CREATION_CHECK_THRESHOLD,
     478          382 :             switch_aux_file_policy: crate::models::AuxFilePolicy::default_tenant_config(),
     479          382 :             lsn_lease_length: LsnLease::DEFAULT_LENGTH,
     480          382 :             lsn_lease_length_for_ts: LsnLease::DEFAULT_LENGTH_FOR_TS,
     481          382 :         }
     482          382 :     }
     483              : }
        

Generated by: LCOV version 2.1-beta