Skip to content

fix(asap-tools): probe the ClickHouse adapter's readiness endpoint - #905

Merged
milindsrivastava1997 merged 1 commit into
mainfrom
fix-clickhouse-engine-readiness
Oct 15, 2026
Merged

milindsrivastava1997 merged 1 commit into
mainfrom
fix-clickhouse-engine-readiness

Conversation

@milindsrivastava1997

Copy link
Copy Markdown
Contributor

Problem: QueryEngineRustService checks readiness by curling /api/v1/status/runtimeinfo, the Prometheus adapter's endpoint. A ClickHouse-backed engine serves /clickhouse/ping instead (clickhouse_http.rs:178) and returns 404 on the Prometheus path, so wait_until_ready timed out after 60 s on every ClickHouse sketchdb run. Seen on CloudLab while testing #874: the engine was up (/clickhouse/ping 200, /api/v1/status/runtimeinfo 404).

Fix: runtime_info_endpoint(backend_type) picks the adapter's endpoint; start() stores it and the readiness check probes it.

Tests: tests/test_victoriametrics_readiness.py.

🤖 Generated with Claude Code

A ClickHouse-backed query engine serves /clickhouse/ping and no
Prometheus API, so the readiness check on /api/v1/status/runtimeinfo
never passed and every ClickHouse sketchdb run timed out after 60 s.
The endpoint now follows the backend type.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@milindsrivastava1997 milindsrivastava1997 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Automated code review (Claude Code). Main issue: Elasticsearch backends still hit the readiness timeout this PR fixes for ClickHouse.

return 8088


def runtime_info_endpoint(backend_type: str) -> str:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

runtime_info_endpoint() maps only "clickhouse"; every other backend falls through to the Prometheus path. elastic_querydsl / elastic_sql use ElasticHttpAdapter, which only routes runtime info at /_cluster/health (elastic_http.rs:232), so the probe 404s and wait_until_ready still times out after 60 s — the same failure this PR fixes for ClickHouse.



def runtime_info_endpoint(backend_type: str) -> str:
"""The readiness endpoint of the engine's query adapter for `backend_type`:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Altitude: this duplicates get_runtime_info_path() from the Rust adapters in Python, and it has already drifted (Elastic missing). servers/http.rs registers /metrics on the same router for every adapter — probing that (or having the engine report its path) would remove the mapping entirely and not break when adapters are added/renamed.

@@ -652,7 +663,7 @@ def _is_runtime_info_ready(self) -> bool:
cmd = (
f"curl -fsS --max-time {constants.HTTP_READINESS_CURL_TIMEOUT_SECONDS} "
f"http://127.0.0.1:{self.get_http_port()}"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The probe uses get_http_port() (hard-coded 8088) rather than the http_port passed to start(); self.http_port is only set when spill=True. If mode_server_urls[sketchdb] (e.g. experiment_run_clickhouse.py:746) uses a non-8088 port, readiness never succeeds regardless of the endpoint fix.

remote_write_port: Port the precompute engine listens on for Prometheus remote
write; should match streaming.remote_write.base_port (default 8080)
"""
self.runtime_info_endpoint = runtime_info_endpoint(backend_config["type"])

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Minor: start() now indexes backend_config["type"] as its first statement, so a backend dict without "type" raises a bare KeyError before the config-generation error path. (resolve_backend_config already indexes it, so only direct callers of start() are affected.)

self.remote_spill_dir: Optional[str] = None
self.local_spill_report: Optional[str] = None
self.http_port: Optional[int] = None
# The started backend's adapter's; set by start().

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nit: the attribute self.runtime_info_endpoint shadows the module-level function runtime_info_endpoint() (line 285 reads like a self-reference), and the comment is missing a noun ("The started backend's adapter's; set by start()."). Consider renaming e.g. readiness_path.

args="curl", returncode=0, stdout="", stderr=""
)
service = QueryEngineRustService(provider, use_container=False, node_offset=0)
service.runtime_info_endpoint = runtime_info_endpoint("clickhouse")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This sets service.runtime_info_endpoint by hand, so the actual fix — start() picking the endpoint from backend_config["type"] — is untested. Deleting the new line in start() leaves this test passing. Driving start() with a mocked provider + clickhouse backend_config and asserting on the probe command would cover it.

provider.execute_command.call_args_list[1].kwargs["cmd"],
)

def test_clickhouse_backed_query_engine_probes_its_adapters_endpoint(self):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nit: a ClickHouse query-engine readiness test lives in test_victoriametrics_readiness.py, and the Prometheus mapping check is appended to the end of the ClickHouse test — if the ClickHouse asserts fail, the Prometheus check never runs. Consider a separate test (and file).

@milindsrivastava1997
milindsrivastava1997 merged commit a48657a into main Oct 15, 2026
11 checks passed
@milindsrivastava1997
milindsrivastava1997 deleted the fix-clickhouse-engine-readiness branch October 15, 2026 14:16
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.

1 participant