1// Copyright Materialize, Inc. and contributors. All rights reserved.
2//
3// Use of this software is governed by the Business Source License
4// included in the LICENSE file.
5//
6// As of the Change Date specified in that file, in accordance with
7// the Business Source License, use of this software will be governed
8// by the Apache License, Version 2.0.
910//! Dyncfgs used by the adapter layer.
1112use std::time::Duration;
1314use mz_dyncfg::{Config, ConfigSet};
1516use crate::timestamp_selection::ConstraintBasedTimestampSelection;
1718pub const ALLOW_USER_SESSIONS: Config<bool> = Config::new(
19"allow_user_sessions",
20true,
21"Whether to allow user roles to create new sessions. When false, only system roles will be permitted to create new sessions.",
22);
2324pub const ENABLE_0DT_DEPLOYMENT: Config<bool> = Config::new(
25"enable_0dt_deployment",
26true,
27"Whether to enable zero-downtime deployments (experimental).",
28);
2930// Slightly awkward with the WITH prefix, but we can't start with a 0.
31pub const WITH_0DT_DEPLOYMENT_MAX_WAIT: Config<Duration> = Config::new(
32"with_0dt_deployment_max_wait",
33 Duration::from_secs(60 * 60),
34"How long to wait at most for clusters to be hydrated, when doing a zero-downtime deployment.",
35);
3637pub const WITH_0DT_DEPLOYMENT_DDL_CHECK_INTERVAL: Config<Duration> = Config::new(
38"with_0dt_deployment_ddl_check_interval",
39 Duration::from_secs(5 * 60),
40"How often to check for DDL changes during zero-downtime deployment.",
41);
4243pub const ENABLE_0DT_DEPLOYMENT_PANIC_AFTER_TIMEOUT: Config<bool> = Config::new(
44"enable_0dt_deployment_panic_after_timeout",
45false,
46"Whether to panic if the maximum wait time is reached but preflight checks have not succeeded.",
47);
4849pub const WITH_0DT_DEPLOYMENT_CAUGHT_UP_CHECK_INTERVAL: Config<Duration> = Config::new(
50// The feature flag name is historical.
51"0dt_deployment_hydration_check_interval",
52 Duration::from_secs(10),
53"Interval at which to check whether clusters are caught up, when doing zero-downtime deployment.",
54);
5556pub const ENABLE_0DT_CAUGHT_UP_CHECK: Config<bool> = Config::new(
57"enable_0dt_caught_up_check",
58true,
59"Whether to determine rehydration using a more complicated method that compares collection write frontiers against an allowed lag behind wall-clock time.",
60);
6162pub const WITH_0DT_CAUGHT_UP_CHECK_ALLOWED_LAG: Config<Duration> = Config::new(
63"with_0dt_caught_up_check_allowed_lag",
64 Duration::from_secs(60),
65"Maximum allowed lag when determining whether collections are caught up for 0dt deployments.",
66);
6768pub const WITH_0DT_CAUGHT_UP_CHECK_CUTOFF: Config<Duration> = Config::new(
69"with_0dt_caught_up_check_cutoff",
70 Duration::from_secs(2 * 60 * 60), // 2 hours
71"Collections whose write frontier is behind 'now' by more than the cutoff are ignored when doing caught-up checks for 0dt deployments.",
72);
7374/// Enable logging of statement lifecycle events in mz_internal.mz_statement_lifecycle_history.
75pub const ENABLE_STATEMENT_LIFECYCLE_LOGGING: Config<bool> = Config::new(
76"enable_statement_lifecycle_logging",
77true,
78"Enable logging of statement lifecycle events in mz_internal.mz_statement_lifecycle_history.",
79);
8081/// Enable installation of introspection subscribes.
82pub const ENABLE_INTROSPECTION_SUBSCRIBES: Config<bool> = Config::new(
83"enable_introspection_subscribes",
84true,
85"Enable installation of introspection subscribes.",
86);
8788/// The plan insights notice will not investigate fast path clusters if plan optimization took longer than this.
89pub const PLAN_INSIGHTS_NOTICE_FAST_PATH_CLUSTERS_OPTIMIZE_DURATION: Config<Duration> = Config::new(
90"plan_insights_notice fast_path_clusters_optimize_duration",
91// Looking at production values of the mz_optimizer_e2e_optimization_time_seconds metric, most
92 // optimizations run faster than 10ms, so this should still work well for most queries. We want
93 // to avoid the case where an optimization took just under this value and there are lots of
94 // clusters, so the extra delay to produce the plan insights notice will take the optimization
95 // time * the number of clusters longer.
96Duration::from_millis(10),
97"Enable plan insights fast path clusters calculation if the optimize step took less than this duration.",
98);
99100/// Whether to create system builtin continual tasks on boot.
101pub const ENABLE_CONTINUAL_TASK_BUILTINS: Config<bool> = Config::new(
102"enable_continual_task_builtins",
103false,
104"Create system builtin continual tasks on boot.",
105);
106107/// Whether to use an expression cache on boot.
108pub const ENABLE_EXPRESSION_CACHE: Config<bool> = Config::new(
109"enable_expression_cache",
110true,
111"Use a cache to store optimized expressions to help speed up start times.",
112);
113114/// Whether we allow sources in multi-replica clusters.
115pub const ENABLE_MULTI_REPLICA_SOURCES: Config<bool> = Config::new(
116"enable_multi_replica_sources",
117false,
118"Enable multi-replica sources.",
119);
120121/// Whether to enable self-managed authentication.
122pub const ENABLE_SELF_MANAGED_AUTH: Config<bool> = Config::new(
123"enable_self_managed_auth",
124false,
125"Enable self-managed authentication.",
126);
127128pub const CONSTRAINT_BASED_TIMESTAMP_SELECTION: Config<&'static str> = Config::new(
129"constraint_based_timestamp_selection",
130 ConstraintBasedTimestampSelection::const_default().as_str(),
131"Whether to use the constraint-based timestamp selection, one of: enabled, disabled, verify",
132);
133134pub const PERSIST_FAST_PATH_ORDER: Config<bool> = Config::new(
135"persist_fast_path_order",
136false,
137"If set, send queries with a compatible literal constraint or ordering clause down the Persist fast path.",
138);
139140/// Adds the full set of all compute `Config`s.
141pub fn all_dyncfgs(configs: ConfigSet) -> ConfigSet {
142 configs
143 .add(&ALLOW_USER_SESSIONS)
144 .add(&ENABLE_0DT_DEPLOYMENT)
145 .add(&WITH_0DT_DEPLOYMENT_MAX_WAIT)
146 .add(&WITH_0DT_DEPLOYMENT_DDL_CHECK_INTERVAL)
147 .add(&ENABLE_0DT_DEPLOYMENT_PANIC_AFTER_TIMEOUT)
148 .add(&WITH_0DT_DEPLOYMENT_CAUGHT_UP_CHECK_INTERVAL)
149 .add(&ENABLE_0DT_CAUGHT_UP_CHECK)
150 .add(&WITH_0DT_CAUGHT_UP_CHECK_ALLOWED_LAG)
151 .add(&WITH_0DT_CAUGHT_UP_CHECK_CUTOFF)
152 .add(&ENABLE_STATEMENT_LIFECYCLE_LOGGING)
153 .add(&ENABLE_INTROSPECTION_SUBSCRIBES)
154 .add(&PLAN_INSIGHTS_NOTICE_FAST_PATH_CLUSTERS_OPTIMIZE_DURATION)
155 .add(&ENABLE_CONTINUAL_TASK_BUILTINS)
156 .add(&ENABLE_EXPRESSION_CACHE)
157 .add(&ENABLE_MULTI_REPLICA_SOURCES)
158 .add(&ENABLE_SELF_MANAGED_AUTH)
159 .add(&CONSTRAINT_BASED_TIMESTAMP_SELECTION)
160 .add(&PERSIST_FAST_PATH_ORDER)
161}