Get icon
Query icon
TransformValue icon
If icon
SlackIncomingWebhook icon
Pause icon
Switch icon
Loop icon
Log icon
LoopUntil icon
Set icon
Schedule icon

StarRocks asynchronous materialized view refresh and drift guard with operator-gated remediation

Detect StarRocks async materialized view refresh failures and inactive schema states, alert on Slack, and gate ALTER/REFRESH remediation on operator approval.

Categories
DataInfrastructure

StarRocks asynchronous materialized views (Async MVs) pre-aggregate multi-table joins, partitioned lakehouse tables (Apache Iceberg, Delta Lake, Hive), and internal Olap tables to deliver sub-second query performance for downstream BI dashboards and customer-facing APIs. When upstream schema drift occurs, network hiccups disrupt compute nodes, or base table partitions fail to sync, materialized view refreshes can fail or become inactive. Without continuous monitoring, analytical queries silently fall back to slow base table scans or serve stale data. This flow audits StarRocks async materialized views on a schedule, detects failed refreshes and inactive states, alerts on Slack with an execution deep-link, pauses for human operator approval, and executes targeted REFRESH MATERIALIZED VIEW or ALTER MATERIALIZED VIEW ... ACTIVE remediation commands before recording the updated health roster in Kestra KV.

How it works

  1. scheduled_poll (io.kestra.plugin.core.trigger.Schedule) triggers every 30 minutes. concurrency.limit: 1 with behavior: CANCEL guarantees that if a run pauses for human operator review, subsequent scheduled executions cancel immediately rather than piling up in an execution queue.
  2. load_previous_state (io.kestra.plugin.core.kv.Get) retrieves the health snapshot saved by the previous run. On initial execution the key is absent and returns null without failing.
  3. probe_materialized_views (io.kestra.plugin.jdbc.mysql.Query) queries information_schema.materialized_views via StarRocks MySQL wire protocol, inspecting refresh types, active flags, refresh states, and error messages for all materialized views in the target database.
  4. evaluate_health_and_drift (io.kestra.plugin.transform.jsonata.TransformValue) filters the returned roster using JSONata to isolate views with LAST_REFRESH_STATE = 'FAIL' or IS_ACTIVE = 0, producing lists of affected views and an alert boolean flag.
  5. check_alerts (io.kestra.plugin.core.flow.If) evaluates outputs.evaluate_health_and_drift.value.has_alerts. If all materialized views are healthy, all subsequent alert and remediation steps are skipped, keeping notification channels completely quiet during normal operations.
  6. send_slack_alert (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) dispatches a formatted alert to Slack detailing degraded view names, failure counts, and a direct link to the execution for one-click operator triage.
  7. await_operator_decision (io.kestra.plugin.core.flow.Pause) halts execution with pauseDuration: PT4H and behavior: CANCEL, waiting for an on-call engineer to review the incident and select a remediation action (refresh_failed_async, activate_and_refresh, force_full_refresh, or acknowledge_and_skip).
  8. remediate_materialized_views (io.kestra.plugin.core.flow.Switch) routes execution to the chosen remediation path, looping through affected views and issuing the corresponding SQL statements against StarRocks.
  9. wait_for_refresh_settlement (io.kestra.plugin.core.flow.LoopUntil) and verify_post_remediation (io.kestra.plugin.jdbc.mysql.Query) poll StarRocks periodically until active refreshes finish running and check if any views remain failed, inactive, or unresolved. check_post_remediation_status (io.kestra.plugin.core.flow.If) then dispatches a follow-up Slack alert if needed.
  10. save_health_state (io.kestra.plugin.core.kv.Set) persists the latest materialized view health roster into the Kestra KV store for historical diffing on subsequent runs.
  11. alert_flow_failure (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) in the top-level errors: block notifies the data engineering team immediately if the StarRocks Frontend FE cannot be reached or credentials fail.

What you get

  • Prompt Slack notifications whenever a StarRocks async materialized view fails to refresh or becomes inactive.
  • Human-gated remediation: operators inspect the failure reason and choose the appropriate refresh command from the Kestra UI before any state-modifying SQL is dispatched.
  • Automated post-remediation verification: re-reads catalog states after asynchronous refresh execution to confirm health.
  • Concurrency protection: concurrency.limit: 1 prevents overlapping executions while waiting for operator review.
  • State persistence in Kestra KV store to maintain operational continuity across scheduled polls.
  • Zero alerting noise when all materialized views are healthy.

Who it's for

  • Data platform teams and analytics engineers running StarRocks for real-time lakehouse acceleration and BI.
  • Database administrators managing critical asynchronous materialized view refresh pipelines.

Why orchestrate this with Kestra

Scripting a materialized view audit with cron and a bash script cannot safely pause mid-stream for an engineer to inspect failure logs before triggering resource-heavy full refreshes. Kestra's Pause and Switch tasks turn incident triage into a declarative, auditable workflow where approvals, execution logs, and remediation statements are captured in a single unified timeline.

Prerequisites

  • A running StarRocks cluster (Frontend FE query port, default 9030).
  • A database containing asynchronous materialized views created with CREATE MATERIALIZED VIEW ... REFRESH ASYNC.
  • A user with SELECT privilege on information_schema.materialized_views and ALTER/REFRESH privileges.
  • A Slack incoming webhook URL for notifications.

Secrets

  • STARROCKS_USERNAME: Username for connecting to the StarRocks Frontend.
  • STARROCKS_PASSWORD: Password for the StarRocks user.
  • SLACK_WEBHOOK_URL: Slack incoming webhook URL for operational notifications.

Quick start

  1. Add STARROCKS_USERNAME, STARROCKS_PASSWORD, and SLACK_WEBHOOK_URL as Kestra secrets.
  2. Set jdbc_url and database_name to match your StarRocks FE host and target schema.
  3. Execute the flow manually once to verify connectivity and seed the KV health state.
  4. Enable the scheduled_poll trigger.
  5. When an alert arrives in Slack, click the execution link, select the remediation action in the Resume form, and click Resume.

How to extend

  • Add a io.kestra.plugin.core.flow.Loop over multiple databases to audit an entire multi-tenant StarRocks cluster in a single scheduled execution.
  • Route critical refresh failures to PagerDuty (io.kestra.plugin.core.http.Request) for tier-1 executive dashboards while routing non-critical views to Slack.
  • Append audit metrics to a DuckDB table or ClickHouse table for long-term SLA tracking.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.