Skip to content

[Enhancement] Reject cross-mode ALTER for materialized view refresh_mode#72380

Merged
Youngwb merged 1 commit into
StarRocks:mainfrom
Youngwb:imv-v1/reject-cross-mode-alter
Apr 30, 2026
Merged

[Enhancement] Reject cross-mode ALTER for materialized view refresh_mode#72380
Youngwb merged 1 commit into
StarRocks:mainfrom
Youngwb:imv-v1/reject-cross-mode-alter

Conversation

@Youngwb

@Youngwb Youngwb commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Why I'm doing:

What I'm doing:

ALTER MATERIALIZED VIEW SET refresh_mode is restricted to no-op (same mode). Switching between INCREMENTAL and PCT is not supported; the recovery path for changing refresh_mode is drop-and-recreate.

Production:

  • AlterMVJobExecutor.alterMVRefreshMode: replace the IVMAnalyzer re-validation block with a single early gate. If the original mode differs from the target mode, throw with a clear error pointing at drop-and-recreate. Same-mode ALTERs still go through the applier so the persisted property and the in-memory currentRefreshMode stay in sync (relied on by the helper-driven test path).
  • The IVMAnalyzer.rewrite call here re-walked the MV's defining query to recompute IVM eligibility on every ALTER refresh_mode. Since same-mode ALTER is the only allowed transition under the new gate, that re-validation is no longer reachable; remove it (and the now unused import) to keep the method narrow and avoid a known AST mutation leak in the analyzer's catch-and-fallback path.

Tests:

  • testChangeMVRefreshMode1 (AUTO MV): AUTO -> INCREMENTAL now expects rejection (cross-mode). The companion AUTO -> AUTO leg still expects rejection at the PropertyAnalyzer layer (PR2). Mode stays AUTO throughout.
  • testChangeMVRefreshMode3 (INCREMENTAL MV): adds a third leg asserting INCREMENTAL -> PCT is rejected, the gap PR6 was created to close.
  • testChangeMVRefreshMode2/6/7 already expect failure for their cross-mode legs and continue to pass under the simpler rule.

Fixes #issue

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
    • This pr needs auto generate documentation
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 4.1
    • 4.0
    • 3.5
    • 3.4

Per the IMV V1 PRD, ALTER MATERIALIZED VIEW SET refresh_mode is
restricted to no-op (same mode). Switching between INCREMENTAL and PCT
is not supported in V1; the recovery path for changing refresh_mode is
drop-and-recreate.

Production:
- AlterMVJobExecutor.alterMVRefreshMode: replace the IVMAnalyzer
  re-validation block with a single early gate. If the original mode
  differs from the target mode, throw with a clear error pointing at
  drop-and-recreate. Same-mode ALTERs still go through the applier so
  the persisted property and the in-memory currentRefreshMode stay in
  sync (relied on by the helper-driven test path).
- The IVMAnalyzer.rewrite call here re-walked the MV's defining query
  to recompute IVM eligibility on every ALTER refresh_mode. Since
  same-mode ALTER is the only allowed transition under the new gate,
  that re-validation is no longer reachable; remove it (and the now
  unused import) to keep the method narrow and avoid a known AST
  mutation leak in the analyzer's catch-and-fallback path.

Tests:
- testChangeMVRefreshMode1 (AUTO MV): AUTO -> INCREMENTAL now expects
  rejection (cross-mode). The companion AUTO -> AUTO leg still expects
  rejection at the PropertyAnalyzer layer (PR2). Mode stays AUTO
  throughout.
- testChangeMVRefreshMode3 (INCREMENTAL MV): adds a third leg
  asserting INCREMENTAL -> PCT is rejected, the gap PR6 was created
  to close.
- testChangeMVRefreshMode2/6/7 already expect failure for their
  cross-mode legs and continue to pass under the simpler rule.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Youngwb <yangwenbo_mailbox@163.com>
@Youngwb Youngwb requested a review from a team as a code owner April 30, 2026 03:01
@github-actions github-actions Bot added the 4.1 label Apr 30, 2026
@github-actions github-actions Bot requested a review from stephen-shelby April 30, 2026 03:05
@CelerData-Reviewer

Copy link
Copy Markdown

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions

Copy link
Copy Markdown
Contributor

[Java-Extensions Incremental Coverage Report]

pass : 0 / 0 (0%)

@github-actions

Copy link
Copy Markdown
Contributor

[FE Incremental Coverage Report]

pass : 6 / 6 (100.00%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/alter/AlterMVJobExecutor.java 6 6 100.00% []

@github-actions

Copy link
Copy Markdown
Contributor

[BE Incremental Coverage Report]

pass : 0 / 0 (0%)

@Youngwb Youngwb merged commit ba99abd into StarRocks:main Apr 30, 2026
82 of 83 checks passed
@Youngwb Youngwb deleted the imv-v1/reject-cross-mode-alter branch April 30, 2026 07:19
@github-actions

Copy link
Copy Markdown
Contributor

@Mergifyio backport branch-4.1

@github-actions github-actions Bot removed the 4.1 label Apr 30, 2026
@mergify

mergify Bot commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

backport branch-4.1

✅ Backports have been created

Details

wanpengfei-git pushed a commit that referenced this pull request Apr 30, 2026
…ode (backport #72380) (#72392)

Signed-off-by: Youngwb <yangwenbo_mailbox@163.com>
Co-authored-by: Youngwb <yangwenbo_mailbox@163.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
robd003 pushed a commit to robd003/starrocks that referenced this pull request May 6, 2026
…ode (StarRocks#72380)

Signed-off-by: Youngwb <yangwenbo_mailbox@163.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
xiangguangyxg pushed a commit to xiangguangyxg/starrocks that referenced this pull request May 7, 2026
…ode (StarRocks#72380)

Signed-off-by: Youngwb <yangwenbo_mailbox@163.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: xiangguangyxg <xiangguangyxg@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants