Skip to content

La Casa Del Dolor: bound the server's wait for backups and restores on shutdown - #128763

Closed
groeneai wants to merge 1 commit into
ClickHouse:masterfrom
groeneai:casa-del-dolor-bounded-backup-shutdown
Closed

groeneai wants to merge 1 commit into
ClickHouse:masterfrom
groeneai:casa-del-dolor-bounded-backup-shutdown

Conversation

@groeneai

@groeneai groeneai commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #94148

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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

...

Description

Server shutdown fails in La Casa Del Dolor on master (amd_debug, arm_asan_ubsan) and in 2 unrelated PRs. The harness force kills a server that has not stopped 30 s after SIGTERM.

The CI job never sets shutdown_wait_backups_and_restores (it is only among the randomly sampled settings, which the job turns off with --server-settings-prob=0), so the servers keep its default true and wait in BackupsWorker::waitAll for every running backup or restore, with no time limit. BuzzHouse runs BACKUP/RESTORE ... ON CLUSTER with backup_restore_keeper_fault_injection_probability up to 1.0. A failed operation then spends 76.3 s in setError Keeper retries, which cannot be cancelled. In 3 of the 4 gdb dumps the main thread is in that wait; in the amd_debug one the operation ended 1 s before the kill.

The servers now always run with shutdown_wait_backups_and_restores = 0, where shutdown_wait_unfinished bounds the wait (#115377). That mode can wait shutdown_wait_unfinished twice: for the cancelled operations, then for the connection of a synchronous BACKUP still waiting for its operation. So its cap is halved from 20 to 10 s. The wait mode stays covered by test_shutdown_wait_backup and test_shutdown_waits_for_backup. Keeping it fuzzed here would need a longer stop window, and that mode has no finite bound to size one by.

Validation on a master debug build: a one-host BACKUP ... ON CLUSTER (and RESTORE) with fault injection 1.0, SIGTERM 3 s later. Time to exit: wait mode 153.7 s, bounded with 20 s 41.5 s, bounded with 10 s 20.1 s. Of 300 configs generated with every setting sampled, 225 used the wait mode and 149 had a cap above 10 s before the change, and none after.

🤖 Generated with Claude Code


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

…hutdown

La Casa Del Dolor force kills a server that has not stopped 30 s after
SIGTERM and reports `Server shutdown` as failed. The generated server
configs set `shutdown_wait_unfinished` but only sometimes sample
`shutdown_wait_backups_and_restores`, so most runs keep its default
`true`. In that mode the server waits in `BackupsWorker::waitAll` for
every running backup or restore, with no time limit. BuzzHouse issues
`BACKUP`/`RESTORE ... ON CLUSTER` with
`backup_restore_keeper_fault_injection_probability` up to 1.0, and a
failed operation then spends 76.3 s in `setError` Keeper retries that
cannot be cancelled, plus up to 180 s in `waitOtherHostsFinish`. In 3
of the 4 gdb dumps of the red runs the main thread is in that wait; in
the amd_debug one the operation ended 1 s before the force kill.

Always run the servers with `shutdown_wait_backups_and_restores = 0`,
where `shutdown_wait_unfinished` bounds the wait. That mode can wait
`shutdown_wait_unfinished` twice: once for the cancelled operations, then
again in `waitServersToFinish` for the connection of a synchronous
`BACKUP` that is still waiting for its operation. So the cap on
`shutdown_wait_unfinished` is halved from 20 to 10 s.

Measured on a master debug build, a one-host `BACKUP ... ON CLUSTER`
with fault injection 1.0 and SIGTERM 3 s later takes this long to exit:
wait mode 153.7 s, bounded mode with 20 s 41.5 s, bounded mode with
10 s 20.1 s, no fault injection 1.9 s.

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

groeneai commented Nov 2, 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 an own cold review (0 blockers, 0 majors).

# Sev Finding Verdict Evidence / action
1 💡 Later shutdown_wait_unfinished drains (Keeper TCP, introspection servers) could add to the stop time DISAGREE None of the CI server configs has keeper_server or protocols, so those drains have nothing to wait for; on the stuck-operation path safeExit(0) runs first

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

Session id: cron:clickhouse-review-slot-8:20261102-212900

@groeneai

groeneai commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. Master debug build, one-host BACKUP ... ON CLUSTER with backup_restore_keeper_fault_injection_probability = 1, SIGTERM 3 s later: the old default config exits after 153.7 s, past the 30 s window, on every run.
b Root cause explained? The CI job never sets shutdown_wait_backups_and_restores (it runs with --server-settings-prob=0), so every server keeps its default true, and that mode waits for a failed operation's 76.3 s of setError Keeper retries, which cannot be cancelled.
c Fix matches root cause? Yes. The servers always run in the mode bounded by shutdown_wait_unfinished, and its cap is sized for the two waits of that mode. The stop window and the backup fuzzing are unchanged.
d Test intent preserved / new tests added? The stop check still catches any shutdown that shutdown_wait_unfinished does not bound. Harness change, so no harness self-test; the wait mode stays covered by test_shutdown_wait_backup and test_shutdown_waits_for_backup.
e Both directions demonstrated? Yes. Wait mode 153.7 s and bounded mode with 20 s 41.5 s (both over 30 s), bounded mode with 10 s 20.1 s; 300 generated configs all in range after the change.
f Fix is general across code paths? Every shutdown_wait_unfinished-bounded wait in Server.cpp was counted. One generated config serves every node, and a base config that sets the key keeps it.
g Fix generalizes across inputs (params/datatypes/wrappers)? BACKUP and RESTORE both measured (153.3 s before, 20.0 s after for RESTORE); both cap boundaries, 0 and 10, are generated.
h Backward compatible? (maintainer-approved exception only) CI harness only, no product behaviour changes.
i Invariants and contracts preserved? Two times shutdown_wait_unfinished plus teardown stays under the 30 s window: 20.1 s measured.

Session id: cron:clickhouse-impl-slot-7:20261102-210600

@groeneai

groeneai commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator Author

cc @maxknv, could you review this and add the can be tested label so CI runs? La Casa Del Dolor servers kept the default shutdown_wait_backups_and_restores = true, so a failed BACKUP ... ON CLUSTER under Keeper fault injection held shutdown for over 76 s, past the 30 s stop window; the harness now always sets it to 0 and caps shutdown_wait_unfinished at 10 s.

@clickhouse-gh

clickhouse-gh Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [cba80b6]

Summary: ✅


AI Review

Summary

This PR configures La Casa Del Dolor to cancel running backups and restores during shutdown and caps shutdown_wait_unfinished at 10 seconds, leaving room for both bounded waits within the existing 30-second stop window. No actionable findings.

Final Verdict

Status: ✅ Approve

@qoega

qoega commented Nov 3, 2026

Copy link
Copy Markdown
Member

@groeneai fix conflict

@groeneai

groeneai commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator Author

@qoega The conflict comes from #128774 (merged 09:28 UTC), which makes the same change: shutdown_wait_backups_and_restores is always 0 and shutdown_wait_unfinished is capped at (SERVER_STOP_WAIT_SECONDS - 10) // 2. Resolving it would leave only a comment rewording, so this PR is superseded. Should I close it?

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-testing Test content only (no production code). pr-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants