Skip to content

Cherry pick #108441 to 26.3: Stop refreshable MV gracefully on Keeper without MULTI_READ on ATTACH/restore - #118300

Merged
robot-ch-test-poll2 merged 5 commits into
backport/26.3/108441from
cherrypick/26.3/108441
Sep 10, 2026
Merged

robot-ch-test-poll2 merged 5 commits into
backport/26.3/108441from
cherrypick/26.3/108441

Conversation

@robot-clickhouse-ci-1

Copy link
Copy Markdown
Contributor

Original pull-request #108441

Do not merge this PR manually

This pull-request is a first step of an automated backporting.
It contains changes similar to calling git cherry-pick locally.
If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.

The check results does not matter at this step - you can safely ignore them.

Troubleshooting

If the conflicts were resolved in a wrong way

If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

groeneai and others added 4 commits June 25, 2026 07:42
…/restore

A coordinated refreshable materialized view (in a Replicated database) crashed
the server when re-attached on a Keeper that lacks the MULTI_READ feature flag,
e.g. after a Keeper downgrade. The constructor's up-front MULTI_READ /
CREATE_IF_NOT_EXISTS check was gated behind the fresh-CREATE path
(!attach && !is_restore_from_backup) inside the !replica_path_existed branch, so
ATTACH / restore / existing-replica kept coordination enabled. The scheduling
thread then threw NOT_IMPLEMENTED in readZnodesIfNeeded, which the doScheduling
catch-all re-raised as a LOGICAL_ERROR, aborting the server (and crash-looping on
restart).

Move the feature-flag check before the znode-create block so it runs on every
coordinated path. Fresh CREATE still rejects with NOT_IMPLEMENTED. On
ATTACH / restore / existing-replica the view now enters a permanent,
non-resumable "coordination unavailable" state: a new coordination.unavailable
flag is set, the task is stopped, and the reason is recorded. doScheduling
short-circuits to Disabled before touching Keeper, so readZnodesIfNeeded is never
reached and the server stays up.

coordination.coordinated is left true on purpose. Clearing it would turn an
originally coordinated view into an uncoordinated one, and a later
SYSTEM START VIEW or finalizeRestoreFromBackup would then resume it as a local
refresh, which breaks the replicated target table of a non-APPEND view in a
Replicated database. start() and finalizeRestoreFromBackup() now also check the
unavailable flag and refuse to resume, so the view stays Disabled until the table
is re-created on a Keeper that supports the required feature flags.

Adds an integration test that creates a coordinated refreshable MV with MULTI_READ
enabled, restarts on a Keeper with MULTI_READ disabled and asserts the server
stays up with the view Disabled, and then asserts SYSTEM START VIEW does not
resume an uncoordinated local refresh.

Closes: #106737

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…ti-read test

SYSTEM REFRESH VIEW is asynchronous: RefreshTask::run sets the state to
Scheduling synchronously and the background scheduler only later reaches the
coordination.unavailable branch and switches it back to Disabled. Reading
system.view_refreshes right after the refresh request could therefore observe
the transient Scheduling state and fail the assertion spuriously.

Add SYSTEM WAIT VIEW after the refresh request (and after the downgrade restart,
which schedules the same graceful-stop pass asynchronously) so the status read
always waits for the scheduled pass. WAIT VIEW returns immediately once the view
is Disabled, so it does not block on the coordination-unavailable view.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…tiread-attach-106737

Stop refreshable MV gracefully on Keeper without MULTI_READ on ATTACH/restore
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default labels Sep 5, 2026
@groeneai

groeneai commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator

The 26.3 cherry-pick conflicts, and I cannot resolve it in place: I have push=false on this repository, and this PR has maintainer_can_modify=false with its head branch upstream.

The conflict is a single hunk in src/Storages/MaterializedView/RefreshTask.h, and its 26.3 side is empty, so resolving it means deleting the three marker lines and keeping the bool unavailable = false; member with its comment. RefreshTask.cpp auto-merges.

I checked that the result is not a half no-op: all 40 added lines of #108441's RefreshTask.cpp hunks are present in the merged tree (control: 22 of those lines are absent from 26.3 itself), and every symbol they use already exists on 26.3 (is_restore_from_backup, finalizeRestoreFromBackup, setState, unexpected_error, MULTI_READ, CREATE_IF_NOT_EXISTS). I have not built 26.3 with it.

One input for the decision: 26.3 has no CI hits of this signature, but that zero is uninformative, because 26.3 does not contain the carrier test (tests/queries/0_stateless/04218_refreshable_mv_secondary_create.sh is 404 on 26.3 and present on 26.6, 26.7 and 26.8). On 26.3 the exposure is a user's own ATTACH rather than CI traffic. The 26.6 backport #118301 came out clean and needs nothing.

So, for the 26.3 half: shall I open a resolution PR from my fork, as in #114814, or would you rather someone with push access resolve cherrypick/26.3/108441 directly, or drop 26.3 and close this PR? I will not push anything until then. This PR is closed automatically after 7 days of inactivity.

@robot-clickhouse-ci-2

Copy link
Copy Markdown
Contributor

Dear @alexey-milovidov, @murphy-4o, @groeneai, this cherry-pick PR has not been updated for 3d0h1m29s. Please resolve the conflicts to backport #108441, or close this PR if the backport is no longer needed. This PR will be automatically closed after 7 days of inactivity.

@groeneai

groeneai commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Three days on: one correction to what I offered, plus two measurements that decide this.

I withdraw the fork-PR option I floated. On 2026-09-05 I offered to open a resolution PR from my fork, as in #114814. I should not have. #117883 was closed with: "You fix a cherry-pick by checking out the source branch, merging the target branch and pushing. A direct PR to the branch is not ok." I take that as ruling out a PR based on 26.3, so the only correct resolution here is a push to cherrypick/26.3/108441, which my push=false on this repository rules out.

The 7-day timer discards the 26.3 backport, it does not renew the nag. In tests/ci/cherry_pick.py, a closed cherry-pick PR takes the discard path (state == "closed" sets _backported = True), and the search that feeds it is not restricted to open PRs, so later runs rediscover the closed PR and discard again. If this lapses, 26.3 quietly never gets the fix and nothing reports it.

Waiting will not clear the conflict either. _retry_cherrypick rebuilds both branches against the current release head on each run, and its usual cause for a stuck conflict is a prerequisite backport that had not landed yet. That is not this one: I rebuilt backport/26.3/108441 on the current 26.3 head (ff33da69) and merged, and it still conflicts on the same single file.

The resolution is one command. On cherrypick/26.3/108441:

git merge --no-ff -X ours backport/26.3/108441
git push origin cherrypick/26.3/108441

-X ours is exact here rather than a shortcut. There is exactly one conflicting hunk and it is a blank line: master had one between bool coordinated and bool read_only in CoordinationState, #108441 replaced it with the unavailable member and its comment, and 26.3 had deleted it. Resolving that hunk by hand gives the same tree as -X ours, 5576f46d, and so does running the command above. What lands on 26.3 is then #108441's own diff plus that blank line, 247 insertions against 246. All 30 added non-blank RefreshTask.cpp lines are present, 20 of them absent from 26.3 itself as a control, and every symbol they use already exists on 26.3, including RefreshState::Disabled and the two-argument setState. The push is a fast-forward, the branch still being at 931d5fd, and the retry skips a hand-resolved branch by design, so it will not be overwritten. I have not built 26.3 with it; the backport PR that opens next gets full CI.

If you would rather merge a PR than push, say so and I will put the same resolved merge up against backport/26.3/108441, the shape of #117893. Otherwise: that command, or close this if 26.3 is not wanted.

Resolve the cherry-pick conflict in `src/Storages/MaterializedView/RefreshTask.h`.

The only conflicting hunk is a blank line inside `CoordinationState`: on master
there was a blank line between `coordinated` and `read_only`, #108441 replaced it
with the `unavailable` member and its comment, and 26.3 had removed that blank
line. The conflict is resolved by keeping #108441's side, which is what the
backport needs.

The resulting tree differs from `backport/26.3/108441` by exactly #108441's own
diff plus that blank line: 247 insertions and 8 deletions against the original
246 and 8.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Resolved and pushed — the PR is now MERGEABLE.

@groeneai your analysis was exactly right, and I pushed the resolution to cherrypick/26.3/108441 (I have push access on this repository, so no fork PR is needed — you were also right to withdraw that option, a PR based on 26.3 is not the way to fix a cherry-pick).

What I did, which is the flow tests/ci/cherry_pick.py itself expects (git merge --no-ff --no-edit backport_branch on the cherry-pick branch, then push):

git merge --no-ff --no-edit backport/26.3/108441
# resolve the single hunk in src/Storages/MaterializedView/RefreshTask.h
git push origin cherrypick/26.3/108441

The one conflicting hunk was the blank line inside CoordinationState between coordinated and read_only: #108441 replaced it with the unavailable member and its comment, and 26.3 had deleted it. I kept #108441's side. RefreshTask.cpp auto-merged.

Two checks that the result is the intended one and not a half no-op:

  • The merge tree is 5576f46dfedb497c2ec11ef613c4d2f2ca24cc47 — the same tree you computed, so the by-hand resolution and -X ours agree.
  • git diff origin/backport/26.3/108441 HEAD is exactly Stop refreshable MV gracefully on Keeper without MULTI_READ on ATTACH/restore #108441's seven files with 247 insertions and 8 deletions, against the original PR's 246 and 8; the extra insertion is that blank line. All of RefreshTask.cpp's hunks are present, and their context lines (is_restore_from_backup, finalizeRestoreFromBackup, startReplicated, scheduling.unexpected_error, setState(RefreshState::Scheduling, lock), getLogger) come from the 26.3 file itself, so every symbol they need already exists there.

I have not merged this PR — the backporting automation does that itself and then opens the actual backport PR against 26.3, which is where CI will build and test the change. The red checks listed here belong to the MasterCI run of 931d5fd8 and, as the PR body says, do not matter at this step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants