Skip to content

Commit 226a3f9

Browse files
authored
Merge pull request #31968 from teskje/wallclock-lag-rollup-view
catalog: add wallclock lag rollup view
2 parents 3e3ccca + a35cbc4 commit 226a3f9

File tree

10 files changed

+62
-10
lines changed

10 files changed

+62
-10
lines changed

doc/user/content/sql/system-catalog/mz_internal.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,6 +1224,17 @@ operations in the system.
12241224
| `created_at` | [`timestamp with time zone`] | The time at which the subscription was created. |
12251225
| `referenced_object_ids` | [`text list`] | The IDs of objects referenced by the subscription. Corresponds to [`mz_objects.id`](../mz_catalog/#mz_objects) |
12261226

1227+
## `mz_wallclock_global_lag`
1228+
1229+
The `mz_wallclock_global_lag` view contains the most recently recorded wallclock lag
1230+
for each table, source, index, materialized view, and sink in the system.
1231+
1232+
<!-- RELATION_SPEC mz_internal.mz_wallclock_global_lag -->
1233+
| Field | Type | Meaning
1234+
| --------------| -------------| --------
1235+
| `object_id` | [`text`] | The ID of the table, source, materialized view, index, or sink. Corresponds to [`mz_objects.id`](../mz_catalog/#mz_objects).
1236+
| `lag` | [`interval`] | The amount of time the object's write frontier lags behind wallclock time.
1237+
12271238
## `mz_wallclock_lag_history`
12281239

12291240
The `mz_wallclock_lag_history` table records the historical wallclock lag,

src/catalog/src/builtin.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3678,6 +3678,19 @@ WHERE occurred_at + '1 day' > mz_now()",
36783678
access: vec![PUBLIC_SELECT],
36793679
});
36803680

3681+
pub static MZ_WALLCLOCK_GLOBAL_LAG: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
3682+
name: "mz_wallclock_global_lag",
3683+
schema: MZ_INTERNAL_SCHEMA,
3684+
oid: oid::VIEW_MZ_WALLCLOCK_GLOBAL_LAG_OID,
3685+
column_defs: None,
3686+
sql: "
3687+
SELECT DISTINCT ON (object_id) object_id, lag
3688+
FROM mz_internal.mz_wallclock_global_lag_recent_history
3689+
WHERE occurred_at + '5 minutes' > mz_now()
3690+
ORDER BY object_id, occurred_at DESC",
3691+
access: vec![PUBLIC_SELECT],
3692+
});
3693+
36813694
pub static MZ_MATERIALIZED_VIEW_REFRESHES: LazyLock<BuiltinSource> =
36823695
LazyLock::new(|| BuiltinSource {
36833696
name: "mz_materialized_view_refreshes",
@@ -9686,6 +9699,7 @@ pub static BUILTINS_STATIC: LazyLock<Vec<Builtin<NameReference>>> = LazyLock::ne
96869699
Builtin::Source(&MZ_WALLCLOCK_LAG_HISTORY),
96879700
Builtin::View(&MZ_WALLCLOCK_GLOBAL_LAG_HISTORY),
96889701
Builtin::View(&MZ_WALLCLOCK_GLOBAL_LAG_RECENT_HISTORY),
9702+
Builtin::View(&MZ_WALLCLOCK_GLOBAL_LAG),
96899703
Builtin::Source(&MZ_MATERIALIZED_VIEW_REFRESHES),
96909704
Builtin::Source(&MZ_COMPUTE_DEPENDENCIES),
96919705
Builtin::Source(&MZ_COMPUTE_OPERATOR_HYDRATION_STATUSES_PER_WORKER),

src/environmentd/tests/testdata/http/ws

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

src/pgrepr-consts/src/oid.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,3 +773,4 @@ pub const INDEX_MZ_CLUSTER_DEPLOYMENT_LINEAGE_IND_OID: u32 = 17050;
773773
pub const INDEX_MZ_CLUSTER_REPLICA_FRONTIERS_IND_OID: u32 = 17051;
774774
pub const INDEX_MZ_COMPUTE_HYDRATION_TIMES_IND_OID: u32 = 17052;
775775
pub const VIEW_MZ_MAPPABLE_OBJECTS_OID: u32 = 17053;
776+
pub const VIEW_MZ_WALLCLOCK_GLOBAL_LAG_OID: u32 = 17054;

test/sqllogictest/autogenerated/mz_internal.slt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,12 @@ SELECT position, name, type FROM objects WHERE schema = 'mz_internal' AND object
637637
4 created_at timestamp␠with␠time␠zone
638638
5 referenced_object_ids list
639639

640+
query ITT
641+
SELECT position, name, type FROM objects WHERE schema = 'mz_internal' AND object = 'mz_wallclock_global_lag' ORDER BY position
642+
----
643+
1 object_id text
644+
2 lag interval
645+
640646
query ITT
641647
SELECT position, name, type FROM objects WHERE schema = 'mz_internal' AND object = 'mz_wallclock_lag_history' ORDER BY position
642648
----
@@ -770,6 +776,7 @@ mz_storage_shards
770776
mz_storage_usage_by_shard
771777
mz_subscriptions
772778
mz_type_pg_metadata
779+
mz_wallclock_global_lag
773780
mz_wallclock_global_lag_history
774781
mz_wallclock_global_lag_recent_history
775782
mz_wallclock_lag_history

test/sqllogictest/information_schema_tables.slt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,10 @@ mz_type_pg_metadata
721721
BASE TABLE
722722
materialize
723723
mz_internal
724+
mz_wallclock_global_lag
725+
VIEW
726+
materialize
727+
mz_internal
724728
mz_wallclock_global_lag_history
725729
VIEW
726730
materialize

test/sqllogictest/mz_catalog_server_index_accounting.slt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ mz_arrangement_heap_capacity_raw_s2_primary_idx CREATE␠INDEX␠"mz_arrangemen
3737
mz_arrangement_heap_size_raw_s2_primary_idx CREATE␠INDEX␠"mz_arrangement_heap_size_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_arrangement_heap_size_raw"␠("operator_id",␠"worker_id")
3838
mz_arrangement_records_raw_s2_primary_idx CREATE␠INDEX␠"mz_arrangement_records_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_arrangement_records_raw"␠("operator_id",␠"worker_id")
3939
mz_arrangement_sharing_raw_s2_primary_idx CREATE␠INDEX␠"mz_arrangement_sharing_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_arrangement_sharing_raw"␠("operator_id",␠"worker_id")
40-
mz_cluster_deployment_lineage_ind CREATE␠INDEX␠"mz_cluster_deployment_lineage_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s722␠AS␠"mz_internal"."mz_cluster_deployment_lineage"]␠("cluster_id")
41-
mz_cluster_replica_frontiers_ind CREATE␠INDEX␠"mz_cluster_replica_frontiers_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s717␠AS␠"mz_catalog"."mz_cluster_replica_frontiers"]␠("object_id")
40+
mz_cluster_deployment_lineage_ind CREATE␠INDEX␠"mz_cluster_deployment_lineage_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s723␠AS␠"mz_internal"."mz_cluster_deployment_lineage"]␠("cluster_id")
41+
mz_cluster_replica_frontiers_ind CREATE␠INDEX␠"mz_cluster_replica_frontiers_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s718␠AS␠"mz_catalog"."mz_cluster_replica_frontiers"]␠("object_id")
4242
mz_cluster_replica_history_ind CREATE␠INDEX␠"mz_cluster_replica_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s584␠AS␠"mz_internal"."mz_cluster_replica_history"]␠("dropped_at")
4343
mz_cluster_replica_metrics_history_ind CREATE␠INDEX␠"mz_cluster_replica_metrics_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s496␠AS␠"mz_internal"."mz_cluster_replica_metrics_history"]␠("replica_id")
4444
mz_cluster_replica_metrics_ind CREATE␠INDEX␠"mz_cluster_replica_metrics_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s495␠AS␠"mz_internal"."mz_cluster_replica_metrics"]␠("replica_id")
@@ -51,17 +51,17 @@ mz_clusters_ind CREATE␠INDEX␠"mz_clusters_ind"␠IN␠CLUSTER␠[s2]␠ON
5151
mz_columns_ind CREATE␠INDEX␠"mz_columns_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s461␠AS␠"mz_catalog"."mz_columns"]␠("name")
5252
mz_comments_ind CREATE␠INDEX␠"mz_comments_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s511␠AS␠"mz_internal"."mz_comments"]␠("id")
5353
mz_compute_dataflow_global_ids_per_worker_s2_primary_idx CREATE␠INDEX␠"mz_compute_dataflow_global_ids_per_worker_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_compute_dataflow_global_ids_per_worker"␠("id",␠"worker_id")
54-
mz_compute_dependencies_ind CREATE␠INDEX␠"mz_compute_dependencies_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s705␠AS␠"mz_internal"."mz_compute_dependencies"]␠("dependency_id")
54+
mz_compute_dependencies_ind CREATE␠INDEX␠"mz_compute_dependencies_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s706␠AS␠"mz_internal"."mz_compute_dependencies"]␠("dependency_id")
5555
mz_compute_error_counts_raw_s2_primary_idx CREATE␠INDEX␠"mz_compute_error_counts_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_compute_error_counts_raw"␠("export_id",␠"worker_id")
5656
mz_compute_exports_per_worker_s2_primary_idx CREATE␠INDEX␠"mz_compute_exports_per_worker_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_compute_exports_per_worker"␠("export_id",␠"worker_id")
5757
mz_compute_frontiers_per_worker_s2_primary_idx CREATE␠INDEX␠"mz_compute_frontiers_per_worker_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_compute_frontiers_per_worker"␠("export_id",␠"worker_id")
58-
mz_compute_hydration_times_ind CREATE␠INDEX␠"mz_compute_hydration_times_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s713␠AS␠"mz_internal"."mz_compute_hydration_times"]␠("replica_id")
58+
mz_compute_hydration_times_ind CREATE␠INDEX␠"mz_compute_hydration_times_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s714␠AS␠"mz_internal"."mz_compute_hydration_times"]␠("replica_id")
5959
mz_compute_hydration_times_per_worker_s2_primary_idx CREATE␠INDEX␠"mz_compute_hydration_times_per_worker_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_compute_hydration_times_per_worker"␠("export_id",␠"worker_id")
6060
mz_compute_import_frontiers_per_worker_s2_primary_idx CREATE␠INDEX␠"mz_compute_import_frontiers_per_worker_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_compute_import_frontiers_per_worker"␠("export_id",␠"import_id",␠"worker_id")
6161
mz_compute_lir_mapping_per_worker_s2_primary_idx CREATE␠INDEX␠"mz_compute_lir_mapping_per_worker_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_compute_lir_mapping_per_worker"␠("global_id",␠"lir_id",␠"worker_id")
6262
mz_compute_operator_durations_histogram_raw_s2_primary_idx CREATE␠INDEX␠"mz_compute_operator_durations_histogram_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_compute_operator_durations_histogram_raw"␠("id",␠"worker_id",␠"duration_ns")
6363
mz_connections_ind CREATE␠INDEX␠"mz_connections_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s492␠AS␠"mz_catalog"."mz_connections"]␠("schema_id")
64-
mz_console_cluster_utilization_overview_ind CREATE␠INDEX␠"mz_console_cluster_utilization_overview_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s709␠AS␠"mz_internal"."mz_console_cluster_utilization_overview"]␠("cluster_id")
64+
mz_console_cluster_utilization_overview_ind CREATE␠INDEX␠"mz_console_cluster_utilization_overview_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s710␠AS␠"mz_internal"."mz_console_cluster_utilization_overview"]␠("cluster_id")
6565
mz_continual_tasks_ind CREATE␠INDEX␠"mz_continual_tasks_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s514␠AS␠"mz_internal"."mz_continual_tasks"]␠("id")
6666
mz_databases_ind CREATE␠INDEX␠"mz_databases_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s459␠AS␠"mz_catalog"."mz_databases"]␠("name")
6767
mz_dataflow_addresses_per_worker_s2_primary_idx CREATE␠INDEX␠"mz_dataflow_addresses_per_worker_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_dataflow_addresses_per_worker"␠("id",␠"worker_id")
@@ -77,7 +77,7 @@ mz_message_batch_counts_received_raw_s2_primary_idx CREATE␠INDEX␠"mz_messag
7777
mz_message_batch_counts_sent_raw_s2_primary_idx CREATE␠INDEX␠"mz_message_batch_counts_sent_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_message_batch_counts_sent_raw"␠("channel_id",␠"from_worker_id",␠"to_worker_id")
7878
mz_message_counts_received_raw_s2_primary_idx CREATE␠INDEX␠"mz_message_counts_received_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_message_counts_received_raw"␠("channel_id",␠"from_worker_id",␠"to_worker_id")
7979
mz_message_counts_sent_raw_s2_primary_idx CREATE␠INDEX␠"mz_message_counts_sent_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_message_counts_sent_raw"␠("channel_id",␠"from_worker_id",␠"to_worker_id")
80-
mz_notices_ind CREATE␠INDEX␠"mz_notices_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s789␠AS␠"mz_internal"."mz_notices"]␠("id")
80+
mz_notices_ind CREATE␠INDEX␠"mz_notices_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s790␠AS␠"mz_internal"."mz_notices"]␠("id")
8181
mz_object_dependencies_ind CREATE␠INDEX␠"mz_object_dependencies_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s458␠AS␠"mz_internal"."mz_object_dependencies"]␠("object_id")
8282
mz_object_history_ind CREATE␠INDEX␠"mz_object_history_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s522␠AS␠"mz_internal"."mz_object_history"]␠("id")
8383
mz_object_lifetimes_ind CREATE␠INDEX␠"mz_object_lifetimes_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s523␠AS␠"mz_internal"."mz_object_lifetimes"]␠("id")
@@ -86,14 +86,14 @@ mz_objects_ind CREATE␠INDEX␠"mz_objects_ind"␠IN␠CLUSTER␠[s2]␠ON␠[
8686
mz_peek_durations_histogram_raw_s2_primary_idx CREATE␠INDEX␠"mz_peek_durations_histogram_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_peek_durations_histogram_raw"␠("worker_id",␠"type",␠"duration_ns")
8787
mz_recent_activity_log_thinned_ind CREATE␠INDEX␠"mz_recent_activity_log_thinned_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s683␠AS␠"mz_internal"."mz_recent_activity_log_thinned"]␠("sql_hash")
8888
mz_recent_sql_text_ind CREATE␠INDEX␠"mz_recent_sql_text_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s679␠AS␠"mz_internal"."mz_recent_sql_text"]␠("sql_hash")
89-
mz_recent_storage_usage_ind CREATE␠INDEX␠"mz_recent_storage_usage_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s781␠AS␠"mz_catalog"."mz_recent_storage_usage"]␠("object_id")
89+
mz_recent_storage_usage_ind CREATE␠INDEX␠"mz_recent_storage_usage_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s782␠AS␠"mz_catalog"."mz_recent_storage_usage"]␠("object_id")
9090
mz_roles_ind CREATE␠INDEX␠"mz_roles_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s481␠AS␠"mz_catalog"."mz_roles"]␠("id")
9191
mz_scheduling_elapsed_raw_s2_primary_idx CREATE␠INDEX␠"mz_scheduling_elapsed_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_scheduling_elapsed_raw"␠("id",␠"worker_id")
9292
mz_scheduling_parks_histogram_raw_s2_primary_idx CREATE␠INDEX␠"mz_scheduling_parks_histogram_raw_s2_primary_idx"␠IN␠CLUSTER␠[s2]␠ON␠"mz_introspection"."mz_scheduling_parks_histogram_raw"␠("worker_id",␠"slept_for_ns",␠"requested_ns")
9393
mz_schemas_ind CREATE␠INDEX␠"mz_schemas_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s460␠AS␠"mz_catalog"."mz_schemas"]␠("database_id")
9494
mz_secrets_ind CREATE␠INDEX␠"mz_secrets_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s491␠AS␠"mz_catalog"."mz_secrets"]␠("name")
9595
mz_show_all_objects_ind CREATE␠INDEX␠"mz_show_all_objects_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s568␠AS␠"mz_internal"."mz_show_all_objects"]␠("schema_id")
96-
mz_show_cluster_replicas_ind CREATE␠INDEX␠"mz_show_cluster_replicas_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s720␠AS␠"mz_internal"."mz_show_cluster_replicas"]␠("cluster")
96+
mz_show_cluster_replicas_ind CREATE␠INDEX␠"mz_show_cluster_replicas_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s721␠AS␠"mz_internal"."mz_show_cluster_replicas"]␠("cluster")
9797
mz_show_clusters_ind CREATE␠INDEX␠"mz_show_clusters_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s570␠AS␠"mz_internal"."mz_show_clusters"]␠("name")
9898
mz_show_columns_ind CREATE␠INDEX␠"mz_show_columns_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s569␠AS␠"mz_internal"."mz_show_columns"]␠("id")
9999
mz_show_connections_ind CREATE␠INDEX␠"mz_show_connections_ind"␠IN␠CLUSTER␠[s2]␠ON␠[s578␠AS␠"mz_internal"."mz_show_connections"]␠("schema_id")

test/sqllogictest/oid.slt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,3 +1163,4 @@ SELECT oid, name FROM mz_objects WHERE id LIKE 's%' AND oid < 20000 ORDER BY oid
11631163
17051 mz_cluster_replica_frontiers_ind
11641164
17052 mz_compute_hydration_times_ind
11651165
17053 mz_mappable_objects
1166+
17054 mz_wallclock_global_lag

test/testdrive/catalog.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,7 @@ mz_source_statuses ""
693693
mz_sql_text_redacted ""
694694
mz_aws_privatelink_connection_statuses ""
695695
mz_statement_execution_history_redacted ""
696+
mz_wallclock_global_lag ""
696697
mz_wallclock_global_lag_history ""
697698
mz_wallclock_global_lag_recent_history ""
698699
pg_class_all_databases ""

test/testdrive/wallclock-lag.td

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,16 @@ snk true true
9696
src true true
9797
src_progress true true
9898
tbl true true
99+
100+
> SELECT o.name, l.lag >= '0s', l.lag < '10s'
101+
FROM mz_internal.mz_wallclock_global_lag l
102+
JOIN mz_objects o ON o.id = l.object_id
103+
WHERE l.object_id LIKE 'u%'
104+
idx true true
105+
idx_const true true
106+
mv true true
107+
mv_const true true
108+
snk true true
109+
src true true
110+
src_progress true true
111+
tbl true true

0 commit comments

Comments
 (0)