starrocks/starrocks-debug-skills/materialized-view
Claude Code and agent skill by starrocks/starrocks-debug-skills
- community
Checking that the SKILL.md file is still in the repository.
Use when async materialized views are failing to refresh, timing out, becoming inactive, or query rewrite is not triggering. Covers refresh OOM (spill-to-disk), timeout tuning, MV reactivation, staleness tolerance for query rewrite, sync MV hit verification via EXPLAIN, FE restart impact on refresh schedules, and S3 rate limiting during refresh.
Install
npx vskill@latest install starrocks/starrocks-debug-skills/materialized-viewSKILL.md
Materialized View Troubleshooting
Investigation guide for async MV refresh failures, refresh timeouts, MV inactivation, query rewrite failures, and sync MV optimization.
Five root causes account for the vast majority of cases:
- Cause A — refresh OOM (memory exhaustion during materialization)
- Cause B — refresh timeout (SQL takes longer than configured limit)
- Cause C — MV inactive (base table schema change or manual deactivation)
- Cause D — query rewrite not used (structural mismatch, staleness, or disabled)
- Cause E — schedule persistence issue (FE restart breaks scheduler timing)
Metric Taxonomy — Read This First
Before using any metrics, understand the three observability layers:
MV state observability
`SHOW MATERIALIZED VIEWS` — primary MV health check:
| Field | Meaning | |
|---|---|---|
is_active | Whether the MV is active (true = can refresh and rewrite) | |
last_refresh_state | State of the last refresh: SUCCESS, FAILED, RUNNING | |
last_refresh_error_message | Error detail when last_refresh_state = FAILED | |
last_refresh_time | Timestamp of the last completed refresh | |
last_refresh_duration_ms | Duration of the last refresh in milliseconds | |
inactive_reason | Why the MV was deactivated (schema change, explicit call) | |
refresh_type | ASYNC / MANUAL / SCHEDULED | |
next_refresh_time | Next scheduled refresh (for scheduled MVs) |
Refresh task observability
Resource consumption observability
Rewrite verification
How to retrieve metrics
Option 1 — SQL (primary method)
Option 2 — FE log grep
Default HTTP ports: FE = 8030. Profile UI at http://<fe_ip>:8030.
Key rules for interpretation:
is_active = falseblocks both refresh and query rewrite — restoring active state is always the first step when queries are not rewriting.last_refresh_state = FAILEDwithlast_refresh_error_messagecontainingOOM→ Cause A. Containingtimeout→ Cause B. Containing schema change → Cause C.- If
last_refresh_timediverges fromnow()by more thanmv_rewrite_staleness_second, the MV will not be used for rewrite unlessquery_rewrite_consistency = LOOSE. TRACE LOGS MVoutput containsMV_REWRITE_FAIL_REASON— read this before assuming structural incompatibility.
MV Issue Reference
| Phenomenon | Root cause | Quick confirmation | |
|---|---|---|---|
| Refresh ends quickly with FAILED state | OOM (Cause A) | last_refresh_error_message contains OOM or heap detail; fe.gc.log shows Full GC | |
| Refresh hangs then fails | Timeout (Cause B) | last_refresh_error_message contains timeout; task_runs.duration_sec > insert_timeout value | |
| MV not refreshing at all | Inactive (Cause C) | is_active = false in SHOW MATERIALIZED VIEWS; check inactive_reason | |
| EXPLAIN shows base table scan despite MV existing | Rewrite not used (Cause D) | TRACE LOGS MV shows MV_REWRITE_FAIL_REASON; or MV is stale / inactive | |
| Scheduled refresh stops firing after FE restart | Schedule persistence (Cause E) | Compare next_refresh_time vs current time; FE log shows wrong initialDelay |
Phase 1 — Confirm MV Issue Type
Step 1.1 — Check overall MV state
Classify based on output:
is_active | last_refresh_state | Classification | |
|---|---|---|---|
| false | any | Cause C — MV inactive (fix active state first) | |
| true | FAILED | Cause A or B (read error message to distinguish) | |
| true | SUCCESS | Cause D — check query rewrite | |
| true | SUCCESS | Cause E — check schedule timing | |
| true | RUNNING for > expected time | Cause B — refresh running too long |
Step 1.2 — Check refresh history
error_messagecontainsOut of memoryorjava.lang.OutOfMemoryError→ Cause Aerror_messagecontainstimeoutorinsert_timeout→ Cause Bstate = FAILED,error_messagecontainsschema→ Cause C- All states SUCCESS but query plan shows base table → Cause D
- No task runs scheduled despite past refresh interval → Cause E
Phase 2 — Investigate Root Cause
Step 2.1 — For FAILED refreshes (Cause A or B)
Step 2.2 — For inactive MV (Cause C)
Step 2.3 — For rewrite miss (Cause D)
Common rewrite blockers:
- Nested aggregation in query not supported by MV structure
- Join + aggregation combination not covered by MV
- Query filter column not included in MV SELECT
- MV data is stale beyond staleness tolerance
query_rewrite_consistency = DISABLEset at session level
Step 2.4 — For schedule persistence (Cause E)
Phase 3 — Take Action by Cause
Cause A — Refresh OOM
Step A-1: Enable spill to disk (immediate, no restart)
Step A-2: Increase FE heap (requires FE restart)
Step A-3: Reduce per-refresh data volume
Step A-4: Emergency stop if OOM is cascading
Cause B — Refresh timeout
Step B-1: Extend timeout (dynamic)
Step B-2: Profile the refresh SQL
Step B-3: Add a resource group for heavy refreshes
Note: default resource group default_mv_wg has cpu_core_limit=1 which throttles large refreshes.
Cause C — MV inactive
Step C-1: Restore active state
Step C-2: If `ACTIVE` fails (schema incompatibility)
Step C-3: Prevent future deactivation from schema changes
When altering base tables that have MVs, test the MV definition against the new schema before applying the DDL. After any base table ALTER TABLE, immediately run:
Cause D — Query rewrite not used
Step D-1: Check staleness tolerance
Step D-2: Check session-level rewrite settings
Step D-3: Trace and fix structural mismatches
Common structural fixes:
Nested aggregation unsupported: flatten the MV definition; avoidSELECT SUM(SUM(x))patternsJoin + aggregation unsupported: separate the join and aggregation, or use a flat MVFilter column not in MV SELECT: add the filter column to MV SELECT
Step D-4: Verify sync MV hit
For sync MVs, supported aggregations: sum, min, max, count, bitmap_union, hll_union. Sync MVs on Duplicate/Aggregate models only — not Primary Key model.
Cause E — Schedule persistence issue
Step E-1: Confirm the broken schedule
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingmaterialized-view/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/starrocks/starrocks-debug-skills/materialized-view)