Aleksandr Zakharchenko
11/17/2026, 9:56 PMRocky
11/17/2026, 9:56 PMALTER MATERIALIZED VIEW <name> ACTIVE works on one MV at a time. So the approach is: generate the statements from information_schema.materialized_views, then execute them.
1. Find the inactive MVs and generate the DDL
sql
SELECT CONCAT('ALTER MATERIALIZED VIEW `', TABLE_SCHEMA, '`.`', TABLE_NAME, '` ACTIVE;') AS stmt
FROM information_schema.materialized_views
WHERE IS_ACTIVE = 'false'
AND REFRESH_TYPE = 'ASYNC';
(REFRESH_TYPE = 'ASYNC' matters because synchronous MVs have empty activation/refresh fields. You can also select INACTIVE_REASON in the same query to see why each one went inactive.)
2. Run the generated statements — copy them out, or script it, e.g.:
bash
mysql -h <fe_host> -P 9030 -u <user> -p -N -e "
SELECT CONCAT('ALTER MATERIALIZED VIEW \`', TABLE_SCHEMA, '\`.\`', TABLE_NAME, '\` ACTIVE;')
FROM information_schema.materialized_views
WHERE IS_ACTIVE = 'false' AND REFRESH_TYPE = 'ASYNC';" \
| while read -r stmt; do mysql -h <fe_host> -P 9030 -u <user> -p -e "$stmt"; done
Caveats worth knowing
• You need the ALTER privilege on each MV.
• Activation re-analyzes the MV definition, so it can fail (e.g. a column it reads was removed from a base view). Per the docs, if setting the state to active doesn't take effect, you have to drop and recreate the MV.
• There are known issues where ALTER MATERIALIZED VIEW ... ACTIVE fails for incremental MVs after being set INACTIVE (fixed in 4.1.4/4.1.6 depending on the variant, no backport to 3.5/4.0) — so if a batch of activations fails, check your version's release notes.
• For monitoring, the mv_inactive_state metric (0 = active, 1 = inactive) is available.
References
• using_starrocks/async_mv/troubleshooting_asynchronous_materialized_views.md
• using_starrocks/async_mv/Materialized_view.md
• knowledge/known_issues/materialized_view.md (StarRocks knowledge base)
• sql-reference/sql-statements/materialized_view/ALTER_MATERIALIZED_VIEW.md
• sql-reference/information_schema/materialized_views.md
• using_starrocks/async_mv/use_cases/data_modeling_with_materialized_views.mdAleksandr Zakharchenko
11/17/2026, 9:58 PMAleksandr Zakharchenko
11/17/2026, 9:59 PMRocky
11/17/2026, 9:59 PMALTER MATERIALIZED VIEW ... ACTIVE — it's a single statement, so the skipping has to happen in whatever runs the loop. A few practical options:
1. Let the client continue on error
The mysql CLI has --force (-f), which keeps going after a failed statement in a batch:
bash
mysql -h <fe> -P 9030 -u <user> -p --force < activate_all.sql
where activate_all.sql is the generated list of ALTER MATERIALIZED VIEW ... ACTIVE; statements. You'll still see each error, but the rest run.
2. Shell loop that ignores failures
bash
... | while read -r stmt; do
mysql -h <fe> -P 9030 -u <user> -p -e "$stmt" || echo "FAILED: $stmt" >> failed.txt
done
This gives you a clean list of the MVs that couldn't be activated, which is what you actually want to act on.
3. Pre-filter the ones that will fail
Select INACTIVE_REASON alongside the name so you can exclude the categories that are known to be unfixable by activation (e.g. a column the MV reads was dropped from a base view). Per the docs, if activation doesn't take effect, the MV has to be dropped and recreated — so those will fail no matter how many times you retry.
4. Consider not doing it manually at all
From v3.1.4 / v3.2.0 there's automatic activation of inactive MVs, controlled by the FE config enable_mv_automatic_active_check (default on). StarRocks also attempts activation before each refresh. If that's enabled in your cluster, MVs that can be activated will come back on their own, and the ones left inactive are the ones that genuinely need a rebuild — which is a useful signal rather than something to force.
One caveat on the "skip" approach: a failed ACTIVE leaves the MV inactive and the reason recorded, so skipping is safe — it doesn't leave anything half-changed. But note the known issues where ALTER ... ACTIVE fails for incremental MVs after INACTIVE (fixed in 4.1.4 / 4.1.6, no backport to 3.5/4.0), so a batch of failures on IVM MVs may be a version bug rather than a definition problem.
References
• sql-reference/sql-statements/materialized_view/ALTER_MATERIALIZED_VIEW.md
• using_starrocks/async_mv/Materialized_view.md
• knowledge/known_issues/materialized_view.md (StarRocks knowledge base)
• sql-reference/sql-statements/materialized_view/CREATE_MATERIALIZED_VIEW.md
• sql-reference/sql-statements/materialized_view/REFRESH_MATERIALIZED_VIEW.md
• using_starrocks/async_mv/troubleshooting_asynchronous_materialized_views.md