Repository navigation
Compare instant vectors from the Prometheus reader regardless of series order in test_prometheus_protocols - #125937
Conversation
…t_prometheus_protocols test_multiple_instant_vectors failed on an unrelated PR (amd_tsan, targeted): the Prometheus "reader", which gets its data from ClickHouse via RemoteRead, returned the two `http_errors` series swapped relative to the "receiver". An instant vector has no defined series order. ClickHouse answers RemoteRead with `GROUP BY timeSeriesIdToGroup(id)` and no ORDER BY, so the series come in the order the tags were read, and Prometheus v3.7.3 passes that order through for an instant vector (only matrices are sorted). Since ClickHouse#121924 this order varies between requests: locally the reader returned the series swapped in 80/600 requests with master 6caeb45 and 0/600 with 5a7acf9, its predecessor. `http_api_response_close_to` compared by raw string (eps == 0) or by index (eps > 0), so an order-only difference failed the test. `http_api_response_close_to` gets `ordered=True`; `ordered=False` sorts the series of a "vector" result by labels on both sides first. It is used only for the reader-vs-receiver comparison. `execute_query_in_prometheus` now returns the receiver's result, and `do_query_test` compares that strictly with the expected result, so an order PromQL defines (for example `topk`, `bottomk` or the `sort` functions) is still checked against Prometheus. ClickHouse's own results are still compared strictly. The unused `expect_error` parameter of `execute_query_in_prometheus` is removed, because the unordered comparison cannot compare error text. With the master CI binary of the base commit, the test fails 8/50 runs before the change and passes 100/100 after; the whole test_evaluation.py module passes 36/36. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 2 findings in the first pass, 0 in the delta recheck after 1 fix round), plus my own review (2 findings + 1 nit).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20261015-034538 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20261015-033400 |
|
Workflow [PR], commit [a2c2f58] Summary: ✅ AI ReviewSummaryThe PR fixes the flaky Prometheus instant-vector comparison by ignoring series order between the reader and receiver while preserving strict expected-result comparisons. No actionable findings. Offline validation passed 1,887 checks across 460 existing JSON fixtures and focused negative controls, reproducing the original CI failure on the base code and accepting it with the fix. The live integration suite was not rerun during this review. Final VerdictStatus: ✅ Approve |
|
cc @nikitamikhaylov, could you review this and add the |
239abff
|
backporting to fix CI |
Backport #125937 to 26.10: Compare instant vectors from the Prometheus reader regardless of series order in test_prometheus_protocols
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix flaky integration test
test_prometheus_protocols/test_evaluation.py::test_multiple_instant_vectors, which compared the series of an instant vector in a fixed order.Description
test_multiple_instant_vectorsfailed on an unrelated PR (CI report): the Prometheus "reader", which reads from ClickHouse via RemoteRead, returned the two series ofhttp_errorsin the opposite order to the "receiver". No related open issue found.An instant vector has no defined series order. ClickHouse answers RemoteRead without sorting the series, and Prometheus passes that order through for an instant vector (it sorts only matrices). Since #121924 the order varies between requests: locally the reader returned the series swapped in 80 of 600 requests with master
6caeb45and in 0 of 600 with5a7acf9, the commit before it.http_api_response_close_tocompared the results by raw string or by position, so the test failed.http_api_response_close_togetsordered=True. Withordered=Falsethe series of avectorresult are sorted by labels on both sides before the comparison. Only the comparison of the reader with the receiver uses it.execute_query_in_prometheusnow returns the receiver's result, anddo_query_testcompares it strictly with the expected one, so an order Prometheus defines (for exampletopkor thesortfunctions) is still checked. ClickHouse's own HTTP API and SQL results are still compared strictly. The unusedexpect_errorparameter ofexecute_query_in_prometheusis removed.Validation, with the master CI binary of the base commit:
test_multiple_instant_vectors --count 50fails 8 of 50 runs before the change and passes 100 of 100 after; the wholetest_evaluation.pymodule passes (36/36). An offline replay of the CI payload shows that value, label, series-count, timestamp and expected-order differences are still detected.Workflow [PR]
Sync PR [sync-upstream/pr/125937]
Version info
26.11.1.21-master(included in26.11and later)26.10.2.43