You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/materialized-view-monitoring.md
+11-5Lines changed: 11 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,7 @@ WHERE type = 'MaterializedView'
36
36
37
37
## States
38
38
39
-
The `system.stream_state_log` stream contains detailed state information that can be used for monitoring and alerting.
39
+
In Timeplus Enterprise 3.0 and later, the `system.introspection_state_log` stream contains detailed state information for monitoring and alerting. In earlier releases, use `system.stream_state_log` instead.
40
40
41
41
Supported states include:
42
42
@@ -57,15 +57,21 @@ Supported states include:
57
57
SELECT
58
58
*
59
59
FROM
60
-
table(system.stream_state_log)
60
+
table(system.introspection_state_log)
61
61
WHERE
62
-
dimension='materialized_view'
62
+
starts_with(dimension, 'materialized_view')
63
63
AND state_name IN ('end_sn', 'processed_sn');
64
64
```
65
65
66
66
## System Built-in Views
67
67
68
-
Timeplus provides built-in system views to help monitor Materialized Views:
68
+
Timeplus provides built-in system views to help monitor and debug Materialized Views:
69
69
70
70
-`system.v_failed_mat_views`: Tracks Materialized Views that have failed.
71
-
-`system.v_mat_view_lags`: Shows Materialized Views with processing lag.
71
+
-`system.v_mat_view_lags`: Shows Materialized Views with processing lag.
72
+
-`system.v_storages`: Shows stream and checkpoint storage usage, which is useful when a Materialized View is accumulating checkpoint data.
73
+
-`system.v_stream_applied_lags`: Shows per-node applied lag for replicated streams when a Materialized View is blocked by upstream replication or storage apply delay.
74
+
75
+
For the full list of built-in troubleshooting views, see [Views in system namespace](/system-views).
76
+
77
+
If you are running a 2.x release, replace `system.introspection_state_log` in the examples above with `system.stream_state_log`.
Timeplus provides system views that enable effective troubleshooting and monitoring of your streaming data operations.
3
3
4
+
In Timeplus Enterprise 3.0 and later, these built-in views are defined on `system.introspection_state_log`. If you are running an older 2.x release, the equivalent state stream is `system.stream_state_log`.
5
+
4
6
## v_failed_mat_views
5
7
```sql
6
8
CREATE OR REPLACEVIEWsystem.v_failed_mat_views
@@ -9,16 +11,16 @@ WITH running_mvs_in_last_5m AS
9
11
(
10
12
SELECT
11
13
database, name
12
-
FROMsystem.stream_state_log
13
-
WHERE (_tp_time > (now() - 5m)) AND (dimension='materialized_view') AND (state_name ='status') AND (state_string_value ='ExecutingPipeline')
14
+
FROMsystem.introspection_state_log
15
+
WHERE (_tp_time > (now() - 5m)) ANDstarts_with(dimension, 'materialized_view') AND (state_name ='status') AND (state_string_value ='Executing')
14
16
ORDER BY _tp_time DESC-- order here to make sure we have the latest state
15
17
SETTINGS query_mode ='table'
16
18
)
17
19
SELECT database, name, state_string_value AS state, _tp_time
18
-
FROMsystem.stream_state_log
19
-
WHERE (_tp_time > (now() - 5m)) AND (dimension='materialized_view') AND (state_name ='status') AND NOT ((database, name) IN running_mvs_in_last_5m)
20
+
FROMsystem.introspection_state_log
21
+
WHERE (_tp_time > (now() - 5m)) ANDstarts_with(dimension,'materialized_view') AND (state_name ='status') AND NOT ((database, name) IN running_mvs_in_last_5m)
20
22
SETTINGS query_mode ='table'
21
-
COMMENT 'version 2';
23
+
COMMENT 'version 3';
22
24
```
23
25
24
26
## v_mat_view_lags
@@ -28,7 +30,7 @@ AS
28
30
WITH last_5m_progressing_status AS
29
31
(
30
32
SELECT database, name, state_name, dimension, state_value, _tp_time AS ts
31
-
FROMsystem.stream_state_log
33
+
FROMsystem.introspection_state_log
32
34
WHERE (_tp_time > (now() - 5m)) AND (state_name IN ('processed_sn', 'ckpt_sn', 'end_sn'))
33
35
ORDER BY _tp_time DESC-- order here to make sure we have latest state
34
36
SETTINGS query_mode ='table'
@@ -67,7 +69,7 @@ SELECT
67
69
if (ckpt_sn !=0AND processed_sn !=0, processed_sn - ckpt_sn, 0) AS ckpt_lag,
68
70
ts
69
71
FROM mv_lagging_aggr_per_mv
70
-
COMMENT 'version 2';
72
+
COMMENT 'version 3';
71
73
```
72
74
73
75
## v_no_leader_shards
@@ -77,23 +79,23 @@ AS
77
79
WITH last_5m_stream_shards AS
78
80
(
79
81
SELECT database, name, dimension AS shard
80
-
FROMsystem.stream_state_log
82
+
FROMsystem.introspection_state_log
81
83
WHERE _tp_time > (now() - 5m) AND state_name ='committed_sn'
82
84
GROUP BY database, name, dimension
83
85
SETTINGS query_mode ='table'
84
86
),
85
87
last_5m_quorum_status AS
86
88
(
87
89
SELECT database, name, dimension AS shard
88
-
FROMsystem.stream_state_log
90
+
FROMsystem.introspection_state_log
89
91
WHERE _tp_time > (now() - 5m) AND state_name ='quorum_replication_status'
90
92
GROUP BY database, name, dimension
91
93
SETTINGS query_mode ='table'
92
94
)
93
95
SELECT database, name, shard
94
96
FROM last_5m_stream_shards
95
97
WHERE (database, name, shard) NOT IN last_5m_quorum_status
96
-
COMMENT 'version 1';
98
+
COMMENT 'version 2';
97
99
```
98
100
99
101
## v_replication_lags
@@ -111,7 +113,7 @@ WITH recent_replication_statuses AS
111
113
array_map(x -> to_uint64(x:node), replica_statuses) AS replica_nodes,
112
114
map_cast(array_map(x -> to_uint64(x:node), replica_statuses), replica_statuses) AS replicas_map,
113
115
_tp_time AS ts
114
-
FROMsystem.stream_state_log
116
+
FROMsystem.introspection_state_log
115
117
WHERE (_tp_time > (now() - 5m)) AND (state_name ='quorum_replication_status')
116
118
ORDER BY _tp_time DESC
117
119
SETTINGS query_mode ='table'
@@ -138,7 +140,7 @@ SELECT
138
140
to_int64((replicas_map[leader_node]):next_sn) - to_int64((replicas_map[replica_node]):next_sn) AS lagging,
139
141
ts
140
142
FROM latest_replication_statuses
141
-
COMMENT 'version 2';
143
+
COMMENT 'version 3';
142
144
```
143
145
144
146
## v_shard_leaders
@@ -148,15 +150,15 @@ AS
148
150
WITH last_5m_quorum_status AS
149
151
(
150
152
SELECT database, name, dimension AS shard, node_id AS leader, _tp_time AS ts
151
-
FROMsystem.stream_state_log
153
+
FROMsystem.introspection_state_log
152
154
WHERE _tp_time > (now() - 5m) AND state_name ='quorum_replication_status'
153
155
ORDER BY _tp_time DESC-- order here to make sure we have latest state
154
156
SETTINGS query_mode ='table'
155
157
)
156
158
SELECT database, name, shard, earliest(leader) AS leader, earliest(ts) AS ts
157
159
FROM last_5m_quorum_status
158
160
GROUP BY database, name, shard
159
-
COMMENT 'version 1';
161
+
COMMENT 'version 2';
160
162
```
161
163
162
164
## v_under_replication_replicas
@@ -174,7 +176,7 @@ WITH recent_replication_statuses AS
174
176
array_map(x -> to_uint64(x:node), replica_statuses) AS replica_nodes,
175
177
map_from_arrays(array_map(x -> to_uint64(x:node), replica_statuses), replica_statuses) AS replicas_map,
176
178
_tp_time AS ts
177
-
FROMsystem.stream_state_log
179
+
FROMsystem.introspection_state_log
178
180
WHERE (_tp_time > (now() - 5m)) AND (state_name ='quorum_replication_status')
179
181
ORDER BY _tp_time DESC
180
182
SETTINGS query_mode ='table'
@@ -195,5 +197,114 @@ latest_replication_statuses AS
195
197
SELECT database, name, shard, leader_node, replica_node, (replicas_map[replica_node]):state AS state, ts
196
198
FROM latest_replication_statuses
197
199
WHERE state !='Replicate'
200
+
COMMENT 'version 3';
201
+
```
202
+
203
+
## v_stream_applied_lags
204
+
```sql
205
+
CREATE OR REPLACEVIEWsystem.v_stream_applied_lags
206
+
AS
207
+
WITH applied_sn_data AS
208
+
(
209
+
SELECT database, name, node_id, state_value AS applied_sn, _tp_time AS ts
210
+
FROMsystem.introspection_state_log
211
+
WHERE (_tp_time > (now() - 5m)) AND (state_name ='applied_sn')
212
+
ORDER BY _tp_time DESC
213
+
SETTINGS query_mode ='table'
214
+
),
215
+
latest_applied_sn_per_node AS
216
+
(
217
+
SELECT database, name, node_id,
218
+
arg_max(applied_sn, ts) AS applied_sn,
219
+
arg_max(ts, ts) AS latest_ts
220
+
FROM applied_sn_data
221
+
GROUP BY database, name, node_id
222
+
),
223
+
quorum_replication_data AS
224
+
(
225
+
SELECT
226
+
database,
227
+
name,
228
+
state_string_value:shard AS shard,
229
+
node_id AS leader_node,
230
+
state_string_value:shard_replication_statuses[*] AS replica_statuses,
231
+
array_map(x -> to_uint64(x:node), replica_statuses) AS replica_nodes,
232
+
map_cast(array_map(x -> to_uint64(x:node), replica_statuses), replica_statuses) AS replicas_map,
233
+
_tp_time AS ts
234
+
FROMsystem.introspection_state_log
235
+
WHERE (_tp_time > (now() - 5m)) AND (state_name ='quorum_replication_status')
0 commit comments