Skip to content

Add SYSTEM PAUSE VIEW and SYSTEM PAUSE VIEWS - #103252

Merged
nikitamikhaylov merged 4 commits into
masterfrom
system-pause-view
May 5, 2026
Merged

nikitamikhaylov merged 4 commits into
masterfrom
system-pause-view

Conversation

@nikitamikhaylov

@nikitamikhaylov nikitamikhaylov commented Apr 21, 2026 •

Copy link
Copy Markdown
Member

Adds new control queries for refreshable materialized views:

SYSTEM PAUSE VIEW [db.]name
SYSTEM PAUSE VIEWS

Unlike SYSTEM STOP VIEW, SYSTEM PAUSE VIEW does not interrupt the currently running refresh — the in-flight refresh is allowed to finish and only subsequent refreshes are prevented. Undone by SYSTEM START VIEW / SYSTEM START VIEWS, which now clear both the stopped and paused states.

Plumbed through the same action-lock path as SYSTEM STOP VIEW via a new ActionLocks::ViewRefreshPause that dispatches to RefreshTask::pause (stop-without-interrupt).

Changelog category (leave one):

  • New Feature

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Added SYSTEM PAUSE VIEW [db.]name and SYSTEM PAUSE VIEWS queries for refreshable materialized views. Unlike SYSTEM STOP VIEW, SYSTEM PAUSE VIEW does not interrupt the currently running refresh — the in-flight refresh is allowed to complete and only subsequent refreshes are prevented. Undone by SYSTEM START VIEW or SYSTEM START VIEWS, which now uniformly clear both the stopped and paused states.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Made with Cursor

Version info

  • Backported to: 26.4.3.8, 26.3.13.12, 26.2.18.7

Unlike `SYSTEM STOP VIEW`, which cancels the currently running refresh,
`SYSTEM PAUSE VIEW` only prevents future refreshes from starting and lets
the ongoing refresh complete normally. Undone by `SYSTEM START VIEW`.

Plumbed through the existing action-lock machinery by adding a new
`ActionLocks::ViewRefreshPause` block type that dispatches to
`RefreshTask::pause` (stop-without-interrupt). `SYSTEM START VIEW` now
drops both the `ViewRefresh` and `ViewRefreshPause` locks so it uniformly
undoes both `STOP` and `PAUSE`.

Made-with: Cursor
@clickhouse-gh

clickhouse-gh Bot commented Apr 21, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [4946102]

Summary: ❌

job_name test_name status info comment
Stress test (arm_tsan) FAIL
Logical error: Port is already connected, (header: [A]) (STID: 0996-3f3c) FAIL cidb, issue ISSUE EXISTS
AST fuzzer (amd_debug) FAIL
Logical error: Not-ready Set is passed as the second argument for function 'A (STID: 0250-4409) FAIL cidb, issue ISSUE EXISTS

AI Review

Summary

This PR adds SYSTEM PAUSE VIEW / SYSTEM PAUSE VIEWS for refreshable materialized views, wires parser/interpreter/access/docs updates, and adds focused stateless coverage including the pause-then-stop regression path. The final patch state is consistent with documented semantics (PAUSE does not interrupt in-flight refresh, STOP does), and I did not find additional blocker/major issues.

ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ✅
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ✅
PR metadata quality ✅
Safe rollout ✅
Compilation time ✅
No large/binary files ✅
Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-feature Pull request with new product feature label Apr 21, 2026
@nikitamikhaylov

Copy link
Copy Markdown
Member Author

Implements a part of #102707

`SYSTEM PAUSE VIEWS` / `SYSTEM START VIEWS` operate server-wide, so a
parallel test that issues `SYSTEM START VIEWS` would race with this
test's assertion that all its views are in the `Disabled` state.
Observed in flaky check at
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=103252&sha=b0daef3f630d999968660b722401fc27ddd48ecb&name_0=PR&name_1=Stateless+tests+%28amd_asan_ubsan%2C+flaky+check%29
(PR: #103252)

Also shrink the slow-refresh workload from 20 rows to 5 rows so the
test stays well under the 180s flaky-check limit.

Made-with: Cursor
`RefreshTask::stop` used `std::exchange(stop_requested, true)` as an
early-return guard. After my previous commit, `RefreshTask::pause` also
sets this flag, so a `SYSTEM STOP VIEW` issued after `SYSTEM PAUSE VIEW`
would hit the early return and skip `interruptExecution`, leaving the
in-flight refresh to run to completion — regressing the documented
`STOP VIEW` semantic.

Keep the guard only for the reschedule call, and always call
`interruptExecution` (which is already idempotent via
`execution.interrupt_execution`).

Added a regression test for the PAUSE-then-STOP sequence.

Review: #103252 (comment)
Made-with: Cursor
@clickhouse-gh

clickhouse-gh Bot commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.00% 84.00% +0.00%
Functions 91.10% 91.10% +0.00%
Branches 76.50% 76.50% +0.00%

Changed lines: 75.00% (63/84) | lost baseline coverage: 34 line(s) · Uncovered code

Full report · Diff report

@nikitamikhaylov
nikitamikhaylov marked this pull request as ready for review April 21, 2026 19:03
@nikitamikhaylov
nikitamikhaylov marked this pull request as draft April 21, 2026 19:05
@nikitamikhaylov
nikitamikhaylov marked this pull request as ready for review April 21, 2026 19:05
@nikitamikhaylov
nikitamikhaylov added this pull request to the merge queue May 5, 2026
Merged via the queue into master with commit f7bb290 May 5, 2026
158 of 161 checks passed
@nikitamikhaylov
nikitamikhaylov deleted the system-pause-view branch May 5, 2026 17:02
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label May 5, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member

@groeneai, this PR was merged by @nikitamikhaylov in violation of our rules - with red CI. I hope this is the last time someone merges with red CI! Our CI is sacred, and we obey its rules.

Now we have tech debt: #104130 and #104129

In both of these issues, please link to the corresponding fixes.

@groeneai

groeneai commented May 5, 2026

Copy link
Copy Markdown
Collaborator

@alexey-milovidov — done. Linked fixes on both tech-debt issues per your directive:

(Posted by groeneai — ClickHouse CI worker. session=cron:clickhouse-ci-task-worker:20260505-194500)

al13n321 added a commit that referenced this pull request May 5, 2026
…IEWS (#104139)

* Add SYSTEM PAUSE VIEW / SYSTEM PAUSE VIEWS

Unlike `SYSTEM STOP VIEW`, which cancels the currently running refresh,
`SYSTEM PAUSE VIEW` only prevents future refreshes from starting and lets
the ongoing refresh complete normally. Undone by `SYSTEM START VIEW`.

Plumbed through the existing action-lock machinery by adding a new
`ActionLocks::ViewRefreshPause` block type that dispatches to
`RefreshTask::pause` (stop-without-interrupt). `SYSTEM START VIEW` now
drops both the `ViewRefresh` and `ViewRefreshPause` locks so it uniformly
undoes both `STOP` and `PAUSE`.

Made-with: Cursor

* Test: mark 04105_system_pause_view as no-parallel and speed up

`SYSTEM PAUSE VIEWS` / `SYSTEM START VIEWS` operate server-wide, so a
parallel test that issues `SYSTEM START VIEWS` would race with this
test's assertion that all its views are in the `Disabled` state.
Observed in flaky check at
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=103252&sha=b0daef3f630d999968660b722401fc27ddd48ecb&name_0=PR&name_1=Stateless+tests+%28amd_asan_ubsan%2C+flaky+check%29
(PR: #103252)

Also shrink the slow-refresh workload from 20 rows to 5 rows so the
test stays well under the 180s flaky-check limit.

Made-with: Cursor

* Fix: SYSTEM STOP VIEW must cancel refresh even after SYSTEM PAUSE VIEW

`RefreshTask::stop` used `std::exchange(stop_requested, true)` as an
early-return guard. After my previous commit, `RefreshTask::pause` also
sets this flag, so a `SYSTEM STOP VIEW` issued after `SYSTEM PAUSE VIEW`
would hit the early return and skip `interruptExecution`, leaving the
in-flight refresh to run to completion — regressing the documented
`STOP VIEW` semantic.

Keep the guard only for the reschedule call, and always call
`interruptExecution` (which is already idempotent via
`execution.interrupt_execution`).

Added a regression test for the PAUSE-then-STOP sequence.

Review: #103252 (comment)
Made-with: Cursor

---------

Co-authored-by: Nikita Mikhailov <[email protected]>
Co-authored-by: Nikita Mikhaylov <[email protected]>
Co-authored-by: Michael Kolupaev <[email protected]>
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label May 6, 2026
alexey-milovidov added a commit that referenced this pull request May 6, 2026
Backport #103252 to 26.2: Add SYSTEM PAUSE VIEW and SYSTEM PAUSE VIEWS
@nikitamikhaylov nikitamikhaylov added pr-must-backport Pull request should be backported intentionally. Use this label with great care! and removed pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore labels May 8, 2026
robot-clickhouse added a commit that referenced this pull request May 8, 2026
Cherry pick #103252 to 26.4: Add SYSTEM PAUSE VIEW and SYSTEM PAUSE VIEWS
fm4v added a commit that referenced this pull request May 11, 2026
Backport #103252 to 26.4: Add SYSTEM PAUSE VIEW and SYSTEM PAUSE VIEWS
robot-ch-test-poll2 added a commit that referenced this pull request May 11, 2026
Cherry pick #103252 to 26.3: Add SYSTEM PAUSE VIEW and SYSTEM PAUSE VIEWS
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label May 11, 2026
al13n321 pushed a commit that referenced this pull request May 25, 2026
@fm4v fm4v removed pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR labels Jun 12, 2026
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Jun 12, 2026
@robot-clickhouse robot-clickhouse added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Jun 12, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…3252

Backport ClickHouse#103252 to 26.4: Add SYSTEM PAUSE VIEW and SYSTEM PAUSE VIEWS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-feature Pull request with new product feature pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v25.12-must-backport v26.2-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants