LCOV - code coverage report
Current view: top level - libs/pageserver_api/src - config.rs (source / functions) Coverage Total Hit
Test: 6fa910d1c9aea142e54ede6987809ef55544c500.info Lines: 93.6 % 140 131
Test Date: 2024-11-19 23:07:42 Functions: 4.9 % 306 15

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

Generated by: LCOV version 2.1-beta