Skip to content

Count the start_clickhouse start budget from the server launch - #132882

Open
groeneai wants to merge 1 commit into
ClickHouse:masterfrom
groeneai:start-clickhouse-budget-from-launch
Open

groeneai wants to merge 1 commit into
ClickHouse:masterfrom
groeneai:start-clickhouse-budget-from-launch

Conversation

@groeneai

@groeneai groeneai commented Nov 19, 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_lazy_load_tables_replica_status/test.py::test_lazy_loaded_replica_is_not_reported_up_to_date failed on master with Cannot start ClickHouse, see additional info in logs while the server was healthy. No related issue.

Failing job: report

start_clickhouse takes its deadline at entry. Its first probe, docker exec ... pgrep, waited 60.5 s in dockerd (exec-added 01:41:28.666, exec-started 01:42:29.193, while other tests' containers were being force-killed), so the 60 s budget was gone before the server existed. The harness launched it, slept 1 s, saw the deadline passed and raised without checking it. The server logged Ready for connections one second later, and the next test used it.

The budget now starts when the first launch docker exec returns. Only the first launch of a call resets it, so a server that dies at startup is still relaunched within one budget. When a server that was already running fails its check, its relaunch gets a full budget, so such a call can take up to about twice start_wait_sec. restart_with_original_version/restart_with_latest_version share the shape but use a combined 300 s stop and start budget with no CI occurrence, so they are unchanged.

Validation (local; no test, since this is test infrastructure): in a scratch module whose in-container pgrep stalls 22 s once before start_clickhouse(start_wait_sec=20), the call raised 3/3 before the change with the CI log sequence and passes 3/3 after. A server with a broken config still raises within the budget, also with the stall; expected_to_fail=True still returns; resetting on every launch instead hangs. test_lazy_load_tables_replica_status, test_system_logs_comment and test_keeper_incorrect_config pass.


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

`start_clickhouse` took its deadline at entry, so time spent in the
harness's own `docker exec` calls before the launch counted against the
server. On a CI host where dockerd stalled, the first `pgrep` probe took
60.5 s, the server was launched with the 60 s budget already gone, the
loop slept 1 s, hit the deadline and raised "Cannot start ClickHouse"
without ever checking the launched server, which was ready 1 s later
(MasterCI 7f13980, Integration tests (amd_asan_ubsan, db disk, 3/8),
test_lazy_load_tables_replica_status).

Reset `start_time` right after the first launch exec of the call returns.
Only the first launch resets it, so a server that dies at startup is still
relaunched within one budget.

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

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

Independent review of 4c4f1ed plus a cold Gate B pass: 0 blockers, 0 majors.

Finding Verdict
💡 When a server already running at entry fails its check early and is relaunched, the relaunch gets a full budget, so one call can take up to about 2 x start_wait_sec. Agreed, by design and stated in the description.
💡 Only the first launch resets the budget, so a stalled probe after a relaunch can still end the call without a new check. By design: resetting on every launch keeps relaunching a server that dies at startup (local run: pytest timeout at 150 s, 128 relaunches).

Session id: cron:clickhouse-review-slot-8:20261119-045300

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @Felixoid, could you review this? start_clickhouse took its deadline at entry, so a 60 s docker exec stall in the first pgrep probe used up the whole start budget and the harness raised on a healthy server; the budget now starts when the first launch exec returns.

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. Scratch module (not committed): an in-container pgrep wrapper stalls the first get_process_pid probe 22 s, then start_clickhouse(start_wait_sec=20). Fails 3/3 before the change with the CI log sequence.
b Root cause explained? The deadline is taken at entry, so time the harness's own docker exec probe spends before the launch counts against the server. When it uses the budget up, the loop launches, sleeps 1 s, hits the deadline and raises with no wait_start on the launched server. In CI the probe waited 60.5 s in dockerd.
c Fix matches root cause? Yes. The budget starts when the first launch exec returns; no budget raised for one test, no retry policy change.
d Test intent preserved / new tests added? Test infrastructure, so no test of it is added; validated locally. The failing test passes.
e Both directions demonstrated? Yes, same rig: FAIL 3/3 before, PASS 3/3 after.
f Fix is general across code paths? Every later use of start_time (loop deadline, wait_start, wait_start_failed) inherits it. restart_with_original_version/restart_with_latest_version share the shape but use a combined 300 s budget and have no CI occurrence; unchanged.
g Fix generalizes across inputs (params/datatypes/wrappers)? Checked: a server that dies at start (still raises within one budget), the same with the stall, expected_to_fail=True, start_wait_sec=10 (test_keeper_incorrect_config), wait_start=False (returns right after the launch).
h Backward compatible? (maintainer-approved exception only) Yes, same signature and defaults. A relaunch after a failed check of an already running server gets a full budget (up to about 2 x start_wait_sec in total).
i Invariants and contracts preserved? Relaunches stay within one budget per call: resetting on every launch instead hangs (pytest timeout at 150 s). A launched server is always checked before the call gives up; the final error message is unchanged.

Session id: cron:clickhouse-impl-slot-40:20261119-041600

@clickhouse-gh

clickhouse-gh Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [4c4f1ed]

Summary: ❌

job_name test_name status info comment
Integration tests (arm_binary, distributed plan, targeted) FAIL
test_grpc_protocol/test.py::test_ipv6_select_one FAIL cidb

AI Review

Summary

The change starts the start_clickhouse startup budget after the first launch returns, preventing earlier Docker delays from exhausting it while keeping subsequent relaunches within the same budget. No actionable findings in head 4c4f1ed9dd255daff320d9660f82131bd661ba14. Eighteen focused mock-clock checks passed, including before/after reproductions for delayed probes and launches, bounded retries, expected startup failures, and launch exception propagation. These checks used the extracted helper methods; Docker integration tests were not rerun during this review.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-ci can be tested Allows running workflows for external contributors comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). labels Nov 19, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 4c4f1ed

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
Integration tests (arm_binary, distributed plan, targeted) / test_grpc_protocol/test.py::test_ipv6_select_one not from this PR (it changes only the server start budget in tests/integration/helpers/cluster.py): the gRPC channel to the instance's IPv6 address is not ready within 10 s (grpc.FutureTimeoutError). test_keeper_ipv4_fallback also ran in this job, and its IPv6 off/on toggle in the job container drops the IPv6 address of docker0. Same red in this targeted job on 11 other PRs since 2026-11-15 #132156 (mine, open)
PR praktika rollup of the row above #132156 (mine, open)

The other CIDB FAIL rows on this head are Config Workflow / Pre Hooks of the runs before the can be tested label. Mergeable Check is red only because of the row above; CH Inc sync is green.

Session id: cron:our-pr-ci-monitor:20261119-073024

@clickhouse-gh clickhouse-gh Bot added comp-testing Test content only (no production code). and removed comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). labels Nov 20, 2026
**({"workdir": DOLOR_CORE_DIR} if self.cluster.with_dolor else {}),
)
# The budget counts from the first launch, not from slow docker calls before it
if first_launch:

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.

the upper start_time looks redundant then

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It is still read before any launch: by the while condition on the first iteration, and by wait_start(start_wait_sec + start_time - time.time()) when a server is already running at entry (no launch there, so the reset never runs; e.g. after a stop_clickhouse whose kill exec raised, which it only logs). Without it the first iteration raises UnboundLocalError, so I'd keep it.

This branch has not been deployed

No deployments
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.

2 participants