mz_storage_client/
healthcheck.rs

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.
9
10use mz_repr::{RelationDesc, ScalarType};
11use std::sync::LazyLock;
12
13pub static MZ_PREPARED_STATEMENT_HISTORY_DESC: LazyLock<RelationDesc> = LazyLock::new(|| {
14    RelationDesc::builder()
15        .with_column("id", ScalarType::Uuid.nullable(false))
16        .with_column("session_id", ScalarType::Uuid.nullable(false))
17        .with_column("name", ScalarType::String.nullable(false))
18        .with_column("sql_hash", ScalarType::Bytes.nullable(false))
19        .with_column(
20            "prepared_at",
21            ScalarType::TimestampTz { precision: None }.nullable(false),
22        )
23        .with_column("statement_type", ScalarType::String.nullable(true))
24        .with_column("throttled_count", ScalarType::UInt64.nullable(false))
25        .finish()
26});
27
28pub static MZ_SQL_TEXT_DESC: LazyLock<RelationDesc> = LazyLock::new(|| {
29    RelationDesc::builder()
30        .with_column(
31            "prepared_day",
32            ScalarType::TimestampTz { precision: None }.nullable(false),
33        )
34        .with_column("sql_hash", ScalarType::Bytes.nullable(false))
35        .with_column("sql", ScalarType::String.nullable(false))
36        .with_column("redacted_sql", ScalarType::String.nullable(false))
37        .finish()
38});
39
40pub static MZ_SESSION_HISTORY_DESC: LazyLock<RelationDesc> = LazyLock::new(|| {
41    RelationDesc::builder()
42        .with_column("session_id", ScalarType::Uuid.nullable(false))
43        .with_column(
44            "connected_at",
45            ScalarType::TimestampTz { precision: None }.nullable(false),
46        )
47        .with_column(
48            "initial_application_name",
49            ScalarType::String.nullable(false),
50        )
51        .with_column("authenticated_user", ScalarType::String.nullable(false))
52        .finish()
53});
54
55// NOTE: Update the views `mz_statement_execution_history_redacted`
56// and `mz_activity_log`, and `mz_activity_log_redacted` whenever this
57// is updated, to include the new columns where appropriate.
58//
59// The `redacted` views should contain only those columns that should
60// be queryable by support.
61pub static MZ_STATEMENT_EXECUTION_HISTORY_DESC: LazyLock<RelationDesc> = LazyLock::new(|| {
62    RelationDesc::builder()
63        .with_column("id", ScalarType::Uuid.nullable(false))
64        .with_column("prepared_statement_id", ScalarType::Uuid.nullable(false))
65        .with_column("sample_rate", ScalarType::Float64.nullable(false))
66        .with_column("cluster_id", ScalarType::String.nullable(true))
67        .with_column("application_name", ScalarType::String.nullable(false))
68        .with_column("cluster_name", ScalarType::String.nullable(true))
69        .with_column("database_name", ScalarType::String.nullable(false))
70        .with_column(
71            "search_path",
72            ScalarType::List {
73                element_type: Box::new(ScalarType::String),
74                custom_id: None,
75            }
76            .nullable(false),
77        )
78        .with_column("transaction_isolation", ScalarType::String.nullable(false))
79        // Note that this can't be a timestamp, as it might be u64::max,
80        // which is out of range.
81        .with_column("execution_timestamp", ScalarType::UInt64.nullable(true))
82        .with_column("transaction_id", ScalarType::UInt64.nullable(false))
83        .with_column("transient_index_id", ScalarType::String.nullable(true))
84        .with_column(
85            "params",
86            ScalarType::Array(Box::new(ScalarType::String)).nullable(false),
87        )
88        .with_column("mz_version", ScalarType::String.nullable(false))
89        .with_column(
90            "began_at",
91            ScalarType::TimestampTz { precision: None }.nullable(false),
92        )
93        .with_column(
94            "finished_at",
95            ScalarType::TimestampTz { precision: None }.nullable(true),
96        )
97        .with_column("finished_status", ScalarType::String.nullable(true))
98        .with_column("error_message", ScalarType::String.nullable(true))
99        .with_column("result_size", ScalarType::Int64.nullable(true))
100        .with_column("rows_returned", ScalarType::Int64.nullable(true))
101        .with_column("execution_strategy", ScalarType::String.nullable(true))
102        .finish()
103});
104
105pub static MZ_SOURCE_STATUS_HISTORY_DESC: LazyLock<RelationDesc> = LazyLock::new(|| {
106    RelationDesc::builder()
107        .with_column(
108            "occurred_at",
109            ScalarType::TimestampTz { precision: None }.nullable(false),
110        )
111        .with_column("source_id", ScalarType::String.nullable(false))
112        .with_column("status", ScalarType::String.nullable(false))
113        .with_column("error", ScalarType::String.nullable(true))
114        .with_column("details", ScalarType::Jsonb.nullable(true))
115        .with_column("replica_id", ScalarType::String.nullable(true))
116        .finish()
117});
118
119pub static MZ_SINK_STATUS_HISTORY_DESC: LazyLock<RelationDesc> = LazyLock::new(|| {
120    RelationDesc::builder()
121        .with_column(
122            "occurred_at",
123            ScalarType::TimestampTz { precision: None }.nullable(false),
124        )
125        .with_column("sink_id", ScalarType::String.nullable(false))
126        .with_column("status", ScalarType::String.nullable(false))
127        .with_column("error", ScalarType::String.nullable(true))
128        .with_column("details", ScalarType::Jsonb.nullable(true))
129        .with_column("replica_id", ScalarType::String.nullable(true))
130        .finish()
131});
132
133pub static MZ_AWS_PRIVATELINK_CONNECTION_STATUS_HISTORY_DESC: LazyLock<RelationDesc> =
134    LazyLock::new(|| {
135        RelationDesc::builder()
136            .with_column(
137                "occurred_at",
138                ScalarType::TimestampTz { precision: None }.nullable(false),
139            )
140            .with_column("connection_id", ScalarType::String.nullable(false))
141            .with_column("status", ScalarType::String.nullable(false))
142            .finish()
143    });
144
145pub static REPLICA_STATUS_HISTORY_DESC: LazyLock<RelationDesc> = LazyLock::new(|| {
146    RelationDesc::builder()
147        .with_column("replica_id", ScalarType::String.nullable(false))
148        .with_column("process_id", ScalarType::UInt64.nullable(false))
149        .with_column("status", ScalarType::String.nullable(false))
150        .with_column("reason", ScalarType::String.nullable(true))
151        .with_column(
152            "occurred_at",
153            ScalarType::TimestampTz { precision: None }.nullable(false),
154        )
155        .finish()
156});
157
158pub static REPLICA_METRICS_HISTORY_DESC: LazyLock<RelationDesc> = LazyLock::new(|| {
159    RelationDesc::builder()
160        .with_column("replica_id", ScalarType::String.nullable(false))
161        .with_column("process_id", ScalarType::UInt64.nullable(false))
162        .with_column("cpu_nano_cores", ScalarType::UInt64.nullable(true))
163        .with_column("memory_bytes", ScalarType::UInt64.nullable(true))
164        .with_column("disk_bytes", ScalarType::UInt64.nullable(true))
165        .with_column(
166            "occurred_at",
167            ScalarType::TimestampTz { precision: None }.nullable(false),
168        )
169        .finish()
170});
171
172pub static WALLCLOCK_LAG_HISTORY_DESC: LazyLock<RelationDesc> = LazyLock::new(|| {
173    RelationDesc::builder()
174        .with_column("object_id", ScalarType::String.nullable(false))
175        .with_column("replica_id", ScalarType::String.nullable(true))
176        .with_column("lag", ScalarType::Interval.nullable(false))
177        .with_column(
178            "occurred_at",
179            ScalarType::TimestampTz { precision: None }.nullable(false),
180        )
181        .finish()
182});
183
184pub static WALLCLOCK_GLOBAL_LAG_HISTOGRAM_RAW_DESC: LazyLock<RelationDesc> = LazyLock::new(|| {
185    RelationDesc::builder()
186        .with_column(
187            "period_start",
188            ScalarType::TimestampTz { precision: None }.nullable(false),
189        )
190        .with_column(
191            "period_end",
192            ScalarType::TimestampTz { precision: None }.nullable(false),
193        )
194        .with_column("object_id", ScalarType::String.nullable(false))
195        .with_column("lag_seconds", ScalarType::UInt64.nullable(false))
196        .with_column("labels", ScalarType::Jsonb.nullable(false))
197        .finish()
198});