Fix max_execution_time not being applied for backup/restore#99205
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
|
Workflow [PR], commit [f36922f] Summary: ✅ AI Review1) SummaryThis PR fixes 2) Missing context (if any)
3) Findings (by severity)
4) Tests & Evidence
5) ClickHouse Compliance Checklist (Yes/No + short note)
6) Performance & Safety Notes
7) User-Lens Review
8) Final Verdict
|
|
Thanks for fixing this, @kssenii 🫂 |
| if (!core_settings.empty()) | ||
| { | ||
| context_->checkSettingsConstraints(core_settings, SettingSource::QUERY); | ||
| context_->applySettingsChanges(core_settings); |
There was a problem hiding this comment.
Do we need the lines
ClickHouse/src/Backups/BackupsWorker.cpp
Lines 389 to 390 in 2fb96d4
There was a problem hiding this comment.
Good point, I think no as we do copy existing query context backup_context(Context::createCopy(query_context)), will remove
There was a problem hiding this comment.
Please remove the same code also from RestoreStarter then
| namespace FailPoints | ||
| { | ||
| extern const char backup_pause_before_main_loop[]; | ||
| extern const char restore_pause_before_main_loop[]; |
There was a problem hiding this comment.
One small thing about naming - backup and restore processes are not loops, they're linear processes from start to finish
LLVM Coverage Report
PR changed lines: PR changed-lines coverage: 100.00% (48/48) |
Backport #99205 to 26.2: Fix max_execution_time not being applied for backup/restore
Backport #99205 to 26.1: Fix max_execution_time not being applied for backup/restore
Issue: ClickHouse#103324 `BACKUP TABLE t TO S3('uri', 'k', 's') SETTINGS base_backup = S3({backup_name:String}, ...) ASYNC` threw `Code: 36. BAD_ARGUMENTS Expected literal, got {backup_name:String}` since PR ClickHouse#99205 (commit `e6721ef7b16`, "Apply settings changes from backup/restore earlier"). The regression hit users on `26.1.5`, `25.12`, `25.10`, `25.8`, `26.2`, `26.3`, `26.4` and `master`. Root cause: PR ClickHouse#99205 added a call to `BackupSettings::fromBackupQuery` (and `RestoreSettings::fromRestoreQuery`) inside `InterpreterSetQuery::applySettingsFromQuery` to surface core settings (e.g. `max_execution_time`) before `ProcessList::insert`. But `fromBackupQuery` unconditionally calls `BackupInfo::fromAST(*query.base_backup_name)`, which only accepts `ASTLiteral` and throws `BAD_ARGUMENTS` on `ASTQueryParameter`. `applySettingsFromQuery` is invoked on the client side from `ClientBase::processOrdinaryQuery` BEFORE `ReplaceQueryParameterVisitor` substitutes parameters, so any `{name:Type}` placeholder inside `base_backup` triggered the throw. The destination URI was unaffected because `fromBackupQuery` does not call `fromAST` on `query.backup_name`. Fix: introduce two lightweight helpers, `BackupSettings::extractCoreSettingsFromQuery` and `RestoreSettings::extractCoreSettingsFromQuery`, that iterate over `query.settings` and return only the non-backup/restore-specific entries. They never look at `base_backup_name`, so they are safe to call before parameter substitution. `InterpreterSetQuery::applySettingsFromQuery` now uses these helpers. The original PR ClickHouse#99205 motivation is preserved -- core settings such as `max_execution_time` still reach the context before `ProcessList::insert`. The existing `BackupsWorker::doBackup` / `BackupsWorker::doRestore` callers continue to use `fromBackupQuery` / `fromRestoreQuery`; by the time they run, parameters have been substituted and `BackupInfo::fromAST` works as before. Bisect credit and proposed fix sketch from `@fm4v`. Regression test: `tests/queries/0_stateless/04213_base_backup_with_query_parameter.sh` covers both `BACKUP` and `RESTORE` paths plus a sanity check that `max_execution_time` can still be passed alongside the parameterized `base_backup` (verifying PR ClickHouse#99205 behaviour). The test fails with `BAD_ARGUMENTS` against unfixed master and passes against this fix.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix max_execution_time not being applied for backup/restore.
Documentation entry for user-facing changes
Note
Medium Risk
Changes when/where BACKUP/RESTORE query settings are applied, which can affect timeouts/limits and cancellation behavior for long-running backup/restore operations. Adds new failpoints used by integration tests; low runtime impact unless explicitly enabled.
Overview
Fixes BACKUP/RESTORE query
SETTINGShandling so core execution limits (e.g.max_execution_time=0) are applied to the query context before theProcessListentry and cancellation checker are created, preventing async backups/restores from being cancelled using profile-level timeouts.Adds pauseable failpoints (
backup_pause_on_start,restore_pause_on_start) and an integration regression test that stalls async backup/restore on a node with a short profile timeout to verify the timeout-disable setting is honored.Written by Cursor Bugbot for commit f36922f. This will update automatically on new commits. Configure here.