Skip to content

Keep BACKUP/RESTORE ON CLUSTER timeouts and Keeper retries when compatibility is 24.10 or older - #123752

Merged
alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:compat-keeps-backup-on-cluster-bounds
Oct 10, 2026
Merged

alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:compat-keeps-backup-on-cluster-bounds

Conversation

@groeneai

@groeneai groeneai commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

Fixed BACKUP / RESTORE ... ON CLUSTER hanging forever, unaffected by KILL QUERY and blocking server shutdown, when compatibility is set to 24.10 or older and a host fails on a Keeper error before it starts. Such a compatibility value no longer sets backup_restore_finish_timeout_after_error_sec, backup_restore_failure_after_host_disconnected_for_seconds, backup_restore_keeper_max_retries_while_initializing and backup_restore_keeper_max_retries_while_handling_error to 0, a combination no release ever used.

Description

On 26.8 (and every release since 24.11), with compatibility set to 24.10 or older, a BACKUP ... ON CLUSTER whose host fails on a Keeper error before it starts never finishes: KILL QUERY does not stop it and the server cannot shut down while it runs.

These four settings came with the 24.11 coordination rewrite, and their New setting history records roll them back to 0. In the current code 0 means no Keeper retries while initializing or handling an error, and no bound on the initiator's wait after an error (BackupCoordinationStageSync::waitOtherHostsFinish). A host that fails its first Keeper step and then fails to write its error never reports anything, so the initiator waits for it forever. Releases before 24.11 had neither behaviour: they retried those steps (20 times) and did not wait for other hosts after an error.

The stress tests randomize compatibility and, since #116783, inject Keeper faults into backups, so the hung check now hits this: 4 times in 10 days, e.g. on master: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=ddae0611a3ab661ca71bd60ed21d202c4a544542&name_0=MasterCI&name_1=Stress%20test%20%28arm_debug%29

The fix adds a CompatibilitySetting::Ignore record (#114190) to each of the four settings, so they keep their defaults under any compatibility. backup_restore_keeper_max_retries still rolls back to 20 (the 24.9 value), and an explicit SET still wins.

Validation: the new test fails on master (four rows 0). On a local server with compatibility = '22.10' and the stress fault probability (0.05), 400 BACKUP ... ON CLUSTER each: master left 11 stuck (up to 73 min, KILL QUERY ... SYNC timed out, no exit 90 s after SIGTERM), this branch 0 (exit in 4 s). test_backup_restore_on_cluster/test_different_versions (profile compatibility 24.9) passes.


Workflow [PR]
Sync PR [sync-upstream/pr/123752]

Version info

  • Merged into: 26.10.1.2069-master (included in 26.10 and later)

…compatibility

The four settings added by the 24.10 BACKUP ON CLUSTER coordination rewrite
(backup_restore_failure_after_host_disconnected_for_seconds,
backup_restore_keeper_max_retries_while_initializing,
backup_restore_keeper_max_retries_while_handling_error,
backup_restore_finish_timeout_after_error_sec) carry "New setting" history
records with a previous value of 0, so compatibility <= 24.10 sets them to 0.
In the current code 0 means no Keeper retries while initializing or handling
an error, no lost-host detection and an untimed wait after an error.

A host that fails its first Keeper step and then fails to write its error
never reports anything, so the initiator's
waitOtherHostsFinish(throw_if_error = false) in BackupStarter::onException
waits forever: KILL QUERY does not stop it and shutdown_wait_backups_and_restores
blocks server shutdown. No release behaved like this: 24.9 retried those
steps with backup_restore_keeper_max_retries (20) and did not wait for other
hosts after an error. Stress tests hit it through compatibility randomization
plus backup Keeper fault injection (ClickHouse#116783).

Add a 26.10 CompatibilitySetting::Ignore record (ClickHouse#114190) to each of the four
settings, so any compatibility value keeps their defaults. The 24.10/24.11
records are unchanged, backup_restore_keeper_max_retries still rolls back to
24.9's 20, and an explicit SET still wins.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding labels Oct 3, 2026
@groeneai

groeneai commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 0 findings) plus my own cold review (1 finding).

# Sev Finding Verdict Evidence / action
1 💡 The description dated the BACKUP ON CLUSTER coordination rewrite to 24.10; it shipped in 24.11 (24.10.4 still has the old BackupCoordinationStageSync) AGREE Description corrected; no code change

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding.

Session id: cron:clickhouse-review-slot-8:20261003-202000

@groeneai

groeneai commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. SET compatibility = '22.10' then system.settings reads 0 for the four settings on master every time (the new test). Behaviourally, 11 of 400 BACKUP ... ON CLUSTER stuck on master at the stress fault probability (0.05), 0 of 400 with the fix.
b Root cause explained? The four settings' New setting history records roll them back to 0 under compatibility <= 24.10, where 0 means no Keeper retries while initializing / handling an error and an untimed after-error wait. A host that fails its first Keeper step and then fails setError never writes started/error/finished, so the initiator's waitOtherHostsFinish(throw_if_error = false) waits forever.
c Fix matches root cause? Yes. The wrong value is first made in the history records; a CompatibilitySetting::Ignore record fixes it there for every consumer (backup and restore, initiator and internal host). No change to the coordination code.
d Test intent preserved / new tests added? New SQL test; deleting any one of the four records turns its row back to 0; backup_restore_keeper_max_retries = 20 is the control that compatibility is still applied.
e Both directions demonstrated? Yes: test fails on master and passes with the fix (local and runner); A/B 11 stuck vs 0 stuck; master server did not exit 90 s after SIGTERM, fix exited in 4 s.
f Fix is general across code paths? RESTORE ON CLUSTER uses the same four settings and the same after-error wait; covered. All other backup*/restore* history records were checked: none rolls back to a value that no release used.
g Fix generalizes across inputs (params/datatypes/wrappers)? Every compatibility below 24.11 (checked 22.10 and 24.10; 24.11 unchanged); an explicit SET of any of the four still wins. No data types involved.
h Backward compatible? (maintainer-approved exception only) Defaults unchanged, history records added (settings-history rule C passes). The removed combination (zero retries plus an unbounded wait) never existed in a release.
i Invariants and contracts preserved? applyCompatibilitySetting semantics unchanged (existing Ignore mechanism); 24.10/24.11 records unchanged, so system.settings_changes still shows when the settings appeared.

Session id: cron:clickhouse-impl-slot-6:20261003-174503

@clickhouse-gh

clickhouse-gh Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [b4c9b1c]

Summary: ✅


AI Review

Summary

This PR fixes a real compatibility regression in BACKUP / RESTORE ... ON CLUSTER: the four coordination-specific settings introduced after 24.10 should not be rolled back to 0 by old compatibility values. Using CompatibilitySetting::Ignore on those four settings is the right scope: it preserves the current bounded timeout / retry behavior while still letting backup_restore_keeper_max_retries roll back to the older 20 value, and the new stateless test exercises exactly that contract. I did not find an unresolved correctness, compatibility, or test-surface issue in the current diff.

Final Verdict
  • Status: ✅ Approve

LLVM Coverage Report

Measured on commit b4c9b1c.

Metric Baseline Current Δ
Lines 88.20% 88.20% +0.00%
Functions 92.10% 92.10% +0.00%
Branches 79.60% 79.70% +0.10%

Changed lines: Changed C/C++ lines covered: 19/19 (100.00%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default comp-backup Backup/restore infrastructure and backup formats. labels Oct 3, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Commit b4c9b1cdb09a80edbdffb127c0cf2bffd00e9825 was not compared: the CI logs cluster did not answer (every POST attempt failed with an exception).

See the job log for details.

@groeneai

groeneai commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - c5a8f25

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Build (amd_fuzzers) / Build ClickHouse not from this PR: the clickhouse_fuzzer link fails with relocation R_X86_64_PC32 out of range; the same job is red on master and on 166 PRs in the last 24h #123738 (external, merged 2026-10-04 01:14Z). This workflow was dispatched at 20:43Z, before that merge, so the fix is not in the tree that ran; a master merge to pick it up follows
Stateless tests (arm_binary, ParallelReplicas, s3 storage, parallel) / 04401_http_query_parameters_not_leaked_to_logs not from this PR: the test was killed at the 600 s timeout; in this lane it takes 3 s at the median but up to 498 s when it passes, and it timed out on 2 unrelated PRs in 30 days a fix task is created (investigating at full effort, fixing-PR link to follow here)
Stateless tests (arm_binary, s3 storage, DBReplicated, parallel, 1/2) / 05237_with_expression_alias_scope_descendant not from this PR: under a Replicated database the replicated CREATE VIEW stores the nested WITH alias qualified with the database, so the view reads the same-named table (view 10 instead of 100); 180 PRs in 24h #123790 (external, open)
Mergeable Check, PR rollups, red only because of the rows above #123738, #123790 and the fix task above

Neither touches the BACKUP ... ON CLUSTER compatibility bounds this PR changes, and 05320_compatibility_keeps_backup_on_cluster_bounds passed. The three arm_binary lanes above come from #122853, which #123789 reverted on master at 00:14Z; #123790 re-lands them. All 157 checks completed and CH Inc sync passed; CIDB has no other FAIL or ERROR on this head.

Session id: cron:our-pr-ci-monitor:20261004-013156

@groeneai

groeneai commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator Author

Fixing PR for 04401_http_query_parameters_not_leaked_to_logs (timeout in the arm_binary ParallelReplicas lane) created: #123814

@groeneai

groeneai commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - b4c9b1c

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stateless tests (arm_binary, parallel) / 05218_text_index_substreams_opened_lazily flaky, not from this PR (which changes only compatibility values in Settings.cpp): the result differs from the reference, and all 16 reruns with the same randomized settings passed. It failed on 9 PRs and 2 master runs in the last 24h #123823 (mine, open)
Performance Comparison (arm_release, master_head, 4/6) / datetime_comparison #1, #4 dashboard confirmed_regression, client_time +15.5% and +15.7%, still +11.5% and +10.2% after the harness restarted both servers; the shard's own report does not call them slower. The queries compare a materialized DateTime or DateTime64 value over numbers(1000000000), which never reaches the backup settings this PR changes. On arm these queries have a slow mode: in the last 7 days #1 was slower on 3 other PRs and #4 on 2 a fix task is created (its fix direction awaits a maintainer decision; fixing-PR link to follow on this PR)
Mergeable Check, PR rollups, red only because of the rows above #123823 (mine, open) and the fix task above

All 146 check runs completed, Finish Workflow is green and CH Inc sync passed. CIDB has no other FAIL or ERROR row on this head.

Session id: cron:our-pr-ci-monitor:20261004-070344

@PedroTadim

Copy link
Copy Markdown
Member

Version 24.10 is no longer supported. @groeneai can you instead create a PR that sets the minimum compatibility version in tests to 26.3?

@PedroTadim PedroTadim closed this Oct 5, 2026
@groeneai

groeneai commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator Author

Acknowledged. I am preparing a new PR that raises the minimum randomized compatibility in tests (the stress runner, ci/jobs/scripts/stress/stress.py) to 26.3, and I will follow up here with the PR link.

@groeneai

groeneai commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator Author

The new PR is #124027: it raises the minimum randomized compatibility to 26.3 in the stress runner, the AST fuzzer and BuzzHouse.

@PedroTadim

Copy link
Copy Markdown
Member

Sorry, this is needed

@PedroTadim PedroTadim reopened this Oct 5, 2026
@groeneai

groeneai commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator Author

Understood, #124027 stays closed and I am dropping the upper-bound change asked there. This PR is unchanged and ready for review.

mohammedImad10 pushed a commit to mohammedImad10/ClickHouse that referenced this pull request Oct 5, 2026
04401_http_query_parameters_not_leaked_to_logs bounded its six
system.text_log reads only by `event_time >= now() - INTERVAL 600 SECOND`,
so every read scanned the last ten minutes of the whole server's log. On
the parallel `Stateless tests (arm_binary, ParallelReplicas, s3 storage,
parallel)` server that is ~4.7M rows / ~120 MB of `message` per scan, and
with `remote_filesystem_read_method = 'read'`, `enable_filesystem_cache = 0`
and 1 MiB remote read tasks the five `message LIKE` scans took 97-222 s
each, so the test hit the 600 s timeout (ClickHouse#123752, ClickHouse#122362).

Take `toUnixTimestamp(now())` before the first request and bound all six
reads with `event_time >= toDateTime(test_start)`, as ClickHouse#123652 did for
05061. Every asserted line is logged after that point, so the reference
is unchanged; text_log is ordered by (event_date, event_time), so the
bound prunes the read to the test's own granules. Locally, with 681K rows
in the ten-minute window, a scan reads 381 rows instead of 681,982.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

@alexey-milovidov alexey-milovidov self-assigned this Oct 10, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 10, 2026
Merged via the queue into ClickHouse:master with commit 39aee24 Oct 10, 2026
293 of 295 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-backup Backup/restore infrastructure and backup formats. groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding pr-bugfix Pull request with bugfix, not backported by default pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants