Skip to content

Retry newly provisioned Query API endpoints until ready - #537

Merged
sdairs merged 2 commits into
stack/451-query-provisioning-single-flightfrom
stack/453-query-endpoint-readiness
Aug 27, 2026
Merged

Retry newly provisioned Query API endpoints until ready#537
sdairs merged 2 commits into
stack/451-query-provisioning-single-flightfrom
stack/453-query-endpoint-readiness

Conversation

@sdairs

@sdairs sdairs commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • wait for newly provisioned Query API endpoints with a harmless SELECT 1 probe, bounded exponential backoff, and a user-visible status message
  • apply the remaining 120-second readiness deadline to every probe and report a generic readiness timeout on exhaustion
  • run user SQL once after readiness while preserving idle wake handling and immediate stopped-service failures

Tests

  • cargo test -p clickhousectl
  • cargo fmt --all --check
  • cargo clippy -p clickhousectl --all-targets -- -D warnings

Closes #453

Comment thread crates/clickhousectl/src/cloud/services.rs
@sdairs

sdairs commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator Author

Carry-over review from PR #504 (old PR for #453). This PR meets the letter of the acceptance criteria and is less invasive (no client.rs test hook; the stopped-service subprocess test is a genuine addition over #504). However it regresses three concerns that were raised and fixed during #504's review (fixes confirmed by sdairs on that PR). Required before merge:

  1. Per-attempt deadline (regressed). On Retry newly provisioned Query API endpoints until ready #504, sdairs confirmed: "Fixed in 4938448. Each readiness attempt is now wrapped in tokio::time::timeout with the remaining overall deadline; expiry returns a clear, non-retryable readiness-timeout error." Here (crates/clickhousectl/src/cloud/services.rs, run_just_provisioned_service_query), the 120s budget is only checked between attempts (if now + backoff > deadline { return Err(error); }). An endpoint that accepts the connection but stalls leaves the CLI hung indefinitely — the budget is illusory for a single stuck attempt. Wrap each attempt in tokio::time::timeout(remaining, ...).

  2. Non-auth error on budget exhaustion (regressed). On Retry newly provisioned Query API endpoints until ready #504, sdairs confirmed: "Completed retryable readiness probes that consume the overall deadline now return the same explicit 408 timeout…" Here, exhaustion returns the last raw 401/403/404, which convert_error maps to CloudErrorKind::Authexit code 4, reporting 2 minutes of propagation delay as "bad credentials". Produce a synthetic non-auth readiness-timeout error ("Query API endpoint did not become ready within …") on expiry and add a test pinning the exhaustion path (there is currently no test covering it).

  3. Probe vs user SQL (partially regressed). On Retry newly provisioned Query API endpoints until ready #504, sdairs confirmed: "Newly provisioned endpoints now retry a bounded SELECT 1 readiness probe. ServiceIdle marks the endpoint ready, and the user query runs once with wake handling outside the readiness deadline." Here the loop re-sends the user's SQL on every retry. That is strictly weaker than a harmless probe (and the subprocess test uses SELECT 1 as the user query, so it cannot detect user-SQL repetition). Either retry with a SELECT 1 probe and run the user query once after readiness, or add a test proving the user SQL is not re-executed.

  4. Minor: no user-visible "waiting for endpoint" indication; the backoff "test" is arithmetic on constants and never executes the loop.

If these are ported, prefer this PR. Otherwise PR #504 is already approved with all of the above fixed and would need only a trivial stopped-service subprocess test added.

@sdairs
sdairs force-pushed the stack/453-query-endpoint-readiness branch from 28ca5e6 to 1f070f9 Compare August 26, 2026 18:58
@sdairs
sdairs force-pushed the stack/453-query-endpoint-readiness branch from 1f070f9 to 0f08ca2 Compare August 26, 2026 19:01
@sdairs
sdairs force-pushed the stack/453-query-endpoint-readiness branch 2 times, most recently from 82b8fd4 to 97516b2 Compare August 26, 2026 19:07
@sdairs
sdairs force-pushed the stack/453-query-endpoint-readiness branch from 97516b2 to 5822500 Compare August 26, 2026 19:10
@sdairs
sdairs force-pushed the stack/453-query-endpoint-readiness branch from 5822500 to 13dbebe Compare August 26, 2026 19:12

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 13dbebe. Configure here.

Comment thread crates/clickhousectl/src/cloud/services.rs Outdated
Comment thread crates/clickhousectl/src/cloud/services.rs Outdated
@sdairs
sdairs force-pushed the stack/453-query-endpoint-readiness branch from 2575a84 to 9379ffd Compare August 27, 2026 10:51
@sdairs
sdairs merged commit 4211ece into main Aug 27, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Retry newly provisioned Query API endpoints until ready

2 participants