Repository navigation
Conversation
Contributor
|
Workflow [PR], commit [9817b9a] Summary: ❌
AI ReviewSummaryThis PR extends Prometheus HTTP handler Final VerdictStatus: ✅ Approve |
This was referenced May 14, 2026
pull Bot
pushed a commit
to infdahai/ClickHouse
that referenced
this pull request
May 17, 2026
…formed_json
Both tests in test_storage_kafka/test_batch_fast.py wait for the
Kafka 'Committed offset 128' log line and then assert the destination
row counts immediately:
instance.wait_for_log_line(f'{kafka_table}.*Committed offset 128')
assert TSV(instance.query(f'SELECT count() FROM test.{kafka_table}_data'))
== TSV('...')
assert TSV(instance.query(f'SELECT count() FROM test.{kafka_table}_errors'))
== TSV('64')
The offset commit and the materialized-view INSERT into the destination
MergeTree are not strictly ordered: the consumer side can log
'Committed offset 128' before the last MV block has finished flushing,
so the immediate SELECT undercounts (typically by exactly the last
block, i.e. assert 54 == 64).
Across both parametrized variants of each test the family has hit 23+
failures across 5 distinct unrelated PRs in the last 30 days (e.g.
ClickHouse#96886, ClickHouse#104902, ClickHouse#104905), with 0 master failures. Surfaced again by
@alexey-milovidov on
ClickHouse#104905 (comment).
The helper file in the same suite already acknowledges this anti-pattern
(tests/integration/helpers/kafka/common.py:463):
"Since everything is async and shaky when receiving messages from
Kafka, we may want to try and check results multiple times in a loop."
Most other tests in test_batch_fast.py already use query_with_retry
with a check_callback for exactly this reason (see e.g. line 1053,
1516). These two tests were the outliers.
Replace the bare assert with query_with_retry + check_callback. The
asserted values are unchanged, so no test intent is weakened: if the
count never reaches the expected value, query_with_retry returns the
last observed result and the surrounding assert ... == EXPECTED fails
loudly.
1 task
Prometheus handlers configured without a pinned <table> now resolve the target TimeSeries table from the X-ClickHouse-Database / X-ClickHouse-Table HTTP headers, in addition to the existing ?database=&table= URL query parameters (added in ClickHouse#104975). Per-field precedence (database and table resolved independently): 1. XML <table> config (pinned; a conflicting query param still errors) 2. ?database= / ?table= URL query parameters 3. X-ClickHouse-Database / X-ClickHouse-Table headers (lowest priority) Header values are consulted only when a name is left unset by both the configuration and the query parameters, are sanitized (ASCII control characters removed) to prevent CRLF header injection, and never error on a conflict with a pinned value. When nothing resolves the table the request fails with a clear error (no implicit default table).
JTCunning
force-pushed
the
feature/prometheus-timeseries-http-headers
branch
from
June 23, 2026 19:21
6d4c8eb to
99decd8
Compare
The factory doc comment referenced the XML table element with bare angle brackets, which clang parses as an unclosed HTML tag and rejects under -Werror,-Wdocumentation-html. Reword to plain text.
…ence Address clickhouse-gh AI Review: prove the changed QueryImpl path resolves its TimeSeries table from the X-ClickHouse-Database / X-ClickHouse-Table headers, and that a handler with a pinned table in config ignores conflicting targeting headers. - Thread extra_headers through the Prometheus HTTP query-API test helpers. - Add a deferred prometheus_api_v1 handler (no table element) to the test config so the query path resolves its target per request. - Add test_deferred_handler_query_api_targets_table_from_headers and test_pinned_handler_ignores_targeting_headers.
…se header A qualified `?table=db.t` query parameter supplied its own database, but getTimeSeriesTableID() filled the database from the lower-priority X-ClickHouse-Database header before splitting the qualified table name. The qualified split was then skipped (database already set), so the target resolved to `<header_db>."db.t"` instead of `db.t` -- a lookup of a non-existent table that fails the request. Split a table supplied by the configuration or the query parameter into database and table before consulting the header, so a qualified table name provides its own database. Header resolution remains the lowest-priority source for names still unset. Adds an integration regression test (test_deferred_handler_qualified_table_param_ignores_database_header) that writes via a deferred handler with `?table=default.hdr_target` and a conflicting `X-ClickHouse-Database: otherdb` header, asserting the sample lands in default.hdr_target and otherdb.hdr_target is untouched.
…resolution Document the `prometheus_metrics`, `prometheus_write`, `prometheus_read`, `prometheus_query` and `prometheus_api_v1` handler types and the per-request `TimeSeries` table resolution order (handler configuration, then the `database`/`table` URL query parameters, then the `X-ClickHouse-Database`/ `X-ClickHouse-Table` HTTP headers) in the `http_handlers` server-configuration section.
…timeseries-http-headers
…ckHouse-Table The Prometheus handler now resolves the TimeSeries table from the config, the ?database=/?table= URL query parameters, or the X-ClickHouse-Table HTTP header only. A qualified database.table in the table header (or any source) supplies its own database, so the separate X-ClickHouse-Database header was redundant for targeting; dropping it also removes the split-before-header edge case and avoids repurposing the standard, often-globally-set X-ClickHouse-Database header. Docs, the factory comment, and the test_prometheus_protocols integration tests are updated to match.
Contributor
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 28/28 (100.00%) | Lost baseline coverage: none · Uncovered code |
Contributor
|
Dear @JTCunning, this PR hasn't been updated for a while. Will you continue working on it? If not, please close it. Otherwise, ignore this message. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prometheus
http_handlersrules that omit a<table>now resolve the targetTimeSeriestable per request, adding theX-ClickHouse-TableHTTP header as a resolution source.This builds on #104975, which added
?database=&table=URL query-parameter targeting for the Prometheus HTTP handlers on the main HTTP port. The only addition here is the header transport.Table-name precedence:
<table>config (pinned; a conflicting query parameter still errors)?table=URL query parameterX-ClickHouse-TableHTTP header (lowest priority)The database is taken from the
<database>config or the?database=query parameter. TheX-ClickHouse-Tableheader is consulted only for a table still unset by both the configuration and the query parameter. Its value is sanitized (ASCII control characters removed) to prevent CRLF header injection, and it never errors on a conflict with a pinned value (this header is often set globally by clients/proxies). The table name may be a qualifieddatabase.tablefrom any source; if no database is resolved otherwise it is taken from the qualified name, falling back todefault. When nothing resolves the table the request fails with a clear error — there is no implicit default table.The
prometheus_api_v1handler and this resolution order are documented under thehttp_handlersserver-configuration section, and the behavior is covered by integration tests intest_prometheus_protocols.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Prometheus protocol HTTP handlers can now resolve the target TimeSeries table from the
X-ClickHouse-Tablerequest header (which may be a qualifieddatabase.table) when no table is pinned in the handler configuration.