Skip to content

Fix flaky test_async_backup_restore_with_max_execution_time_zero on slow CI lanes - #108567

Merged
jkartseva merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-flaky-async-backup-restore-max-exec-time-setup
Jul 2, 2026
Merged

jkartseva merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-flaky-async-backup-restore-max-exec-time-setup

Conversation

@groeneai

@groeneai groeneai commented Jun 26, 2026 •

Copy link
Copy Markdown
Collaborator

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

test_backup_restore_new/test.py::test_async_backup_restore_with_max_execution_time_zero is flaky on the amd_msan integration lane (3 failures across 3 unrelated PRs in the last 30 days, 0 on master).

The instance_with_short_timeout node sets max_execution_time = 0.5 in its default profile so the profile-level timeout reliably fires on the paused async BACKUP/RESTORE task (that timeout firing is the bug under test). That same 0.5s cap also applies to the test's foreground setup INSERT and final verification SELECT, which are not part of what the test checks. On a slow sanitizer lane the setup INSERT's pipeline finalization exceeded 500ms and the query failed before the test could run:

test.py:2263: in test_async_backup_restore_with_max_execution_time_zero
    inst.query("INSERT INTO test.table SELECT number, toString(number) FROM numbers(100)")
Code: 159. DB::Exception: Timeout exceeded: elapsed 532.921871 ms, maximum: 500 ms. (TIMEOUT_EXCEEDED)
  5. ExecutionSpeedLimits::checkTimeLimit
  6. QueryStatus::checkTimeLimit()
  7. PipelineExecutor::finalizeExecution()

Fix: add SETTINGS max_execution_time = 0 to those two foreground scaffolding queries so a loaded lane cannot time them out. The profile cap and the async BACKUP/RESTORE query settings are unchanged, so the bug-detection mechanism is fully preserved: the failpoint still pauses the background task past the 0.5s profile timeout, and the system.backups status assertions still catch a regression of the original bug (profile max_execution_time cached in QueryStatus and not overridden by the query's max_execution_time = 0).

CI report: https://s3.amazonaws.com/clickhouse-test-reports/PRs/108184/480c9f8720e5d3d4c01cfa755d357a1df7f8f097/integration_tests_amd_msan_4_6/job.log

Version info

  • Merged into: 26.7.1.405 (included in 26.7 and later)

…low CI lanes

The instance_with_short_timeout node sets max_execution_time = 0.5 in its
default profile to trigger the bug under test (the profile-level timeout
must fire on the paused async BACKUP/RESTORE). That same 0.5s cap also
applies to the foreground setup INSERT and the final verification SELECT,
which are not part of what the test checks. On a slow sanitizer lane
(amd_msan) the setup INSERT's pipeline finalization exceeded 500ms and
failed with Code 159 TIMEOUT_EXCEEDED before the test could run, e.g.
elapsed 532.9ms > maximum 500ms in QueryStatus::checkTimeLimit.

Scope max_execution_time = 0 to those two foreground scaffolding queries so
a loaded lane can't time them out. The profile cap and the async query
settings are unchanged, so the bug-detection mechanism is fully preserved.

CIDB: 3 failures across 3 unrelated PRs, all on amd_msan, 0 on master.

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

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. clickhouse local --max_execution_time=0.001 -q "SELECT count() FROM (SELECT cityHash64(number) h FROM numbers(500000000)) WHERE h%7=0" (a ~1.3s pipeline) fails with Code: 159 TIMEOUT_EXCEEDED, maximum: 0.001 via the same PipelineExecutor::finalizeExecution -> QueryStatus::checkTimeLimit -> ExecutionSpeedLimits::checkTimeLimit path as the CI stack.
b Root cause explained? The instance_with_short_timeout node sets max_execution_time = 0.5 in its default profile (configs/max_execution_time.xml) to make the profile timeout fire on the paused async backup/restore (the bug-detection mechanism). That cap also applies to the foreground setup INSERT (test.py:2263); on the slow amd_msan lane its pipeline finalization took 532.9ms > 500ms -> Code 159 in setup, before the assertion ran.
c Fix matches root cause? Yes. Adds query-level SETTINGS max_execution_time = 0 to only the two foreground scaffolding queries (setup INSERT, final verification SELECT), exempting them from the leaked cap. No bounds widened, no data reduced, no no-random-* tag.
d Test intent preserved / new tests added? Preserved. The profile cap and the async BACKUP/RESTORE query settings are unchanged; the failpoint + sleep(0.7) still force the profile timeout on the background task, and the system.backups status assertions still catch a regression of the original bug.
e Both directions demonstrated? Yes. Same heavy query under --max_execution_time=0.001 -> Code 159 (bug); with query-level SETTINGS max_execution_time = 0 -> succeeds (fix). This is the precedence the fix relies on.
f Fix is general across code paths? N/A (flaky integration-test setting fix, not a code bug).
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (flaky integration-test setting fix, not a code bug).
h Backward compatible? (maintainer-approved exception only) N/A (test-only change).
i Invariants and contracts preserved? N/A (test-only change); the test's bug-detection contract is preserved as noted in (d).

Session id: cron:clickhouse-worker-slot-0:20260626-025700

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @vitlibar - could you review this? Test-only fix: the instance_with_short_timeout node's 0.5s profile max_execution_time (kept to trigger the bug on the paused async BACKUP/RESTORE) was also capping the foreground setup INSERT and verification SELECT, timing them out on the slow amd_msan lane (532.9ms > 500ms). It scopes max_execution_time = 0 to just those two scaffolding queries; the profile cap and async query settings are unchanged, so the bug-detection mechanism is preserved.

@nikitamikhaylov nikitamikhaylov added the can be tested Allows running workflows for external contributors label Jun 26, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2e30a6b]

Summary: ❌

job_name test_name status info comment
Integration tests (arm_binary, distributed plan, 1/4) FAIL
test_kafka_bad_messages/test.py::test_bad_messages_parsing_stream FAIL cidb IGNORED

AI Review

Summary

This PR makes the foreground setup INSERT and final verification SELECT in test_async_backup_restore_with_max_execution_time_zero opt out of the test node's short profile-level max_execution_time, while leaving the async BACKUP/RESTORE operations and failpoint timing that exercise the regression unchanged. I did not find a correctness or reliability issue in the current diff.

Missing context / blind spots
  • ⚠️ I did not run the targeted integration test locally; the PR CI report I fetched currently shows no failed checks, but the specific slow amd_msan integration lane is not represented as a completed validation in that report.
Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jun 26, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.40% 85.40% +0.00%
Functions 92.60% 92.60% +0.00%
Branches 77.60% 77.60% +0.00%

Changed lines: No C/C++ source files changed — skipping uncovered code analysis.

Newly covered by added/modified tests: 488 line(s), 25 function(s) across 135 file(s) · Details

Top files
  • src/Backups/BackupEntriesCollector.cpp: 27 line(s), 2 function(s)
  • src/Databases/PostgreSQL/fetchPostgreSQLTableStructure.cpp: 23 line(s)
  • src/Functions/catboostEvaluate.cpp: 19 line(s), 5 function(s)
  • src/Processors/Formats/Impl/Parquet/Decoding.cpp: 18 line(s)
  • src/Common/ZooKeeper/ZooKeeper.cpp: 16 line(s), 2 function(s)

Full report

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 2e30a6b

Every failure below has an owner: a fixing PR (ours 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
Integration tests (arm_binary, distributed plan, 1/4) / test_kafka_bad_messages::test_bad_messages_parsing_stream flaky (4 unrelated PRs/30d, 0 master; failure is in the kafka_delete_topic teardown, not the assertion body; unrelated to this backup-restore test fix) a fix task is created (investigating at full effort, fixing-PR link to follow here)

This PR is a test-only fix to test_backup_restore_new/test.py (scope SETTINGS max_execution_time = 0 to the foreground setup INSERT + verification SELECT). The single failure is a Kafka integration teardown flake, not in this PR's changed file. Finish Workflow + Style check pass on this head.

Session id: cron:our-pr-ci-monitor:20260626-170000

@groeneai

Copy link
Copy Markdown
Collaborator Author

Fixing PR for the test_kafka_bad_messages::test_bad_messages_parsing_stream topic-delete teardown flaky created: #108635

@jkartseva jkartseva self-assigned this Jun 29, 2026

@jkartseva jkartseva 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.

LGTM

@jkartseva
jkartseva enabled auto-merge June 29, 2026 04:38
@jkartseva
jkartseva added this pull request to the merge queue Jul 2, 2026
Merged via the queue into ClickHouse:master with commit ce5447e Jul 2, 2026
165 of 167 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 2, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…ckup-restore-max-exec-time-setup

Fix flaky test_async_backup_restore_with_max_execution_time_zero on slow CI lanes
nihalzp pushed a commit to nihalzp/ClickHouse that referenced this pull request Oct 11, 2026
…xecution_time_zero on BACKUP/RESTORE only

The node instance_with_short_timeout sets max_execution_time = 0.5 in its
default profile, which is how the test checks that an async BACKUP/RESTORE
honours its own SETTINGS max_execution_time = 0. The profile caps every
other query on the node too: a DDL statement that runs past its deadline is
marked killed by the CancellationChecker and fails its post-execute check
with TIMEOUT_EXCEEDED. On slow lanes (amd_msan, amd_asan_ubsan db disk) this
failed the test on CREATE DATABASE, CREATE TABLE and DROP DATABASE, which
ClickHouse#108567 did not cover (it exempted only the INSERT and the final SELECT).

Run every query except the BACKUP and RESTORE under test through a local
helper that passes a client-level max_execution_time = 0. A client-level
setting is used instead of inline SETTINGS clauses because it works the
same way for every statement, including the SYSTEM FAILPOINT statements and
the system.backups polls, while on CREATE TABLE ... ENGINE=MergeTree an
inline clause would read as a MergeTree setting. The BACKUP and RESTORE
statements, the profile and the fail points are unchanged, so the test
still fails if either statement ignores its max_execution_time = 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 pr-ci 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