Repository navigation
Make the "Inconsistent KeyCondition behavior" logical error actionable - #108011
Conversation
`MergeTreeDataSelectExecutor::markRangesFromPKRange` throws the `LOGICAL_ERROR` "Inconsistent KeyCondition behavior" (debug builds only, guarded by `#ifndef NDEBUG`) when `KeyCondition::matchesExactContinuousRange` reports a single exact continuous range but the binary-search result range turns out not to be exactly continuous. This is the canary for functions reporting inaccurate monotonicity tracked in #90461. The message carried no context, so each stress-test / fuzzer occurrence was opaque: there was no way to tell which `KeyCondition`, part, or mark range triggered it. Log the key condition, the part name, the relaxed flag, and the offending mark ranges right before throwing. The thrown exception message is deliberately kept byte-for-byte unchanged. CI derives the failure name from the exception's format string (see `ci/jobs/scripts/log_parser.py`), so keeping the message constant preserves the existing grouping (`Logical error: Inconsistent KeyCondition behavior`); the high-cardinality details go to `clickhouse-server.err.log` instead, which is a captured CI artifact. No behavior change in release builds (the branch is compiled out under `NDEBUG`; the suspect range is excluded from `exact_ranges` as before). Failing test history: https://play.clickhouse.com/play?user=play&run=1#V0lUSAogICAgOTAgQVMgaW50ZXJ2YWxfZGF5cwpTRUxFQ1QKICAgIHRvU3RhcnRPZkRheShjaGVja19zdGFydF90aW1lKSBBUyBkYXksCiAgICBjb3VudCgpIEFTIGZhaWx1cmVzLAogICAgZ3JvdXBVbmlxQXJyYXkocHVsbF9yZXF1ZXN0X251bWJlcikgQVMgcHJzLAogICAgYW55KHJlcG9ydF91cmwpIEFTIHJlcG9ydF91cmwKRlJPTSBjaGVja3MKV0hFUkUgKG5vdygpIC0gdG9JbnRlcnZhbERheShpbnRlcnZhbF9kYXlzKSkgPD0gY2hlY2tfc3RhcnRfdGltZQogICAgQU5EIHRlc3RfbmFtZSA9ICdMb2dpY2FsIGVycm9yOiBJbmNvbnNpc3RlbnQgS2V5Q29uZGl0aW9uIGJlaGF2aW9yIChTVElEOiA1MTgyLTJmMjcpJwogICAgLS0gQU5EIGNoZWNrX25hbWUgPSAnU3RyZXNzIHRlc3QgKGFybV9kZWJ1ZyknCiAgICBBTkQgdGVzdF9zdGF0dXMgSU4gKCdGQUlMJywgJ0VSUk9SJykKICAgIEFORCAocHVsbF9yZXF1ZXN0X251bWJlciA9IDAgT1IgYmFzZV9yZWYgSU4gKCdtYXN0ZXInKSkKICAgIEFORCB0ZXN0X2NvbnRleHRfcmF3IExJS0UgJyVFeGNlcHRpb246JScKR1JPVVAgQlkgZGF5Ck9SREVSIEJZIGRheSBERVNDCg== Related: #90461 Related: #98075 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Workflow [PR], commit [ab7231f] Summary: ✅
AI ReviewSummaryThis PR augments the debug-only Missing context / blind spots
Final Verdict✅ No new inline findings. The existing bot-authored thread is already resolved and the current code no longer has that diagnostic coverage gap. |
…havior" diagnostic The diagnostic logged only the primary `key_condition`, but the binary-search path in `markRangesFromPKRange` is taken only when every useful condition reported an exact continuous range, and `check_in_range` combines `key_condition`, `part_offset_condition` and `total_offset_condition`. A bad `_part_offset` or total-offset condition can therefore trip the throw while `key_condition` is empty or unrelated, leaving the log non-actionable. Log every participating condition (with its `useful` and `relaxed` flags) so the occurrence is actionable for all callers of this path, not just for queries that exercise the primary key condition. Addresses review feedback. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
@groeneai, fix the error found by fuzzer: |
|
@alexey-milovidov Triaged STID 3721-419e. Error: Reproducer (exact, AST fuzzer amd_msan — report): SELECT minDistinct(c0 >= (SELECT minSimpleState(*) FROM (SELECT DISTINCT toLowCardinality('1') GROUP BY GROUPING SETS ((1))))) FROM (SELECT 1 AS c0 LIMIT 197) AS t0 SETTINGS group_by_use_nulls = 1;The crashing aggregate is the inner Root cause family: |
|
Fixed. STID 3721-419e is the constant-LowCardinality variant of the #91119 Fix + regression test pushed to my existing #91119 PR #104350 (commit ec6b58a), since it is the same family and same file. Both directions verified locally (aborts on master, passes patched; the projected type is now |
…om `04338_on_fly_mutation_read_overwritten_lc_source` The stateless test `04338_on_fly_mutation_read_overwritten_lc_source` (table `t_overwrite_before_consume`) chains the async mutations `UPDATE v = toString(id + 100)`, `UPDATE b = isNotNull(materialize(v))` and `MODIFY COLUMN v UInt64` over a column whose on-disk value is the unconvertible String `'x'`. This is an intentionally-broken mutation of exactly the class already documented in the `CANNOT_PARSE_TEXT` allowlist (issue ClickHouse#39174): a `MODIFY COLUMN ... UInt64` on un-parseable String data, just like the already-allowlisted `'Hello'`/`'a'`/`'b'` variants from `00834_kill_mutation` and `01414_mutations_and_errors_zookeeper`. After the upgrade restart the broken mutation is retried and logs `Cannot parse string 'x' as UInt64: syntax error at begin of string` (`CANNOT_PARSE_TEXT`) to `clickhouse-server.upgrade.log`, which fails the `Upgrade check` with `Error message in clickhouse-server.log (see upgrade_error_messages.txt)`. This is not a backward-incompatibility or a regression; it is the expected test-induced error. Add the narrow `'x'` message to the upgrade-check allowlist and document `04338` in the comment block. The failure is not caused by any product change - it surfaces on any pull request that runs the Upgrade check (observed on PR ClickHouse#108011 and the unrelated PR ClickHouse#107433). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…t-keycondition-diagnostics
…t-keycondition-diagnostics
|
Merged the latest The only red checks are |
|
Reviewed the current state via Status: The only red checks are unrelated —
The earlier fuzzer finding ( I re-ran the failed stress jobs to give the flaky Hung check another pass. No code change is needed and no master re-merge (merge-base is <1 day old and the red is not fixed on |
…t-keycondition-diagnostics
|
Merged the latest Re-merging (rather than only re-running the flaky stress jobs, as before) because the situation changed since my last pass:
Verified after the merge:
The only prior red checks were the two TSan stress jobs, both the #107941 hung-check flake (CI auto-links each occurrence to it; the hung stacks are generic |
|
Follow-up on the re-merge: the fresh CI run on
So the re-merge did clear the chronic Net diff is unchanged: |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 1/1 (100.00%) · Uncovered code |
…om `04338_on_fly_mutation_read_overwritten_lc_source` The stateless test `04338_on_fly_mutation_read_overwritten_lc_source` (table `t_overwrite_before_consume`) chains the async mutations `UPDATE v = toString(id + 100)`, `UPDATE b = isNotNull(materialize(v))` and `MODIFY COLUMN v UInt64` over a column whose on-disk value is the unconvertible String `'x'`. This is an intentionally-broken mutation of exactly the class already documented in the `CANNOT_PARSE_TEXT` allowlist (issue ClickHouse#39174): a `MODIFY COLUMN ... UInt64` on un-parseable String data, just like the already-allowlisted `'Hello'`/`'a'`/`'b'` variants from `00834_kill_mutation` and `01414_mutations_and_errors_zookeeper`. After the upgrade restart the broken mutation is retried and logs `Cannot parse string 'x' as UInt64: syntax error at begin of string` (`CANNOT_PARSE_TEXT`) to `clickhouse-server.upgrade.log`, which fails the `Upgrade check` with `Error message in clickhouse-server.log (see upgrade_error_messages.txt)`. This is not a backward-incompatibility or a regression; it is the expected test-induced error. Add the narrow `'x'` message to the upgrade-check allowlist and document `04338` in the comment block. The failure is not caused by any product change - it surfaces on any pull request that runs the Upgrade check (observed on PR ClickHouse#108011 and the unrelated PR ClickHouse#107433). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…tent-keycondition-diagnostics Make the "Inconsistent KeyCondition behavior" logical error actionable
Related: #90461
Related: #98075
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Make the debug-only
Inconsistent KeyCondition behaviorlogical error actionable by logging the offendingKeyCondition, part and mark ranges.Documentation entry for user-facing changes
Description / motivation
MergeTreeDataSelectExecutor::markRangesFromPKRangeraises theLOGICAL_ERRORInconsistent KeyCondition behavior(debug builds only, guarded by#ifndef NDEBUG)when
KeyCondition::matchesExactContinuousRangereports a single exact continuousrange, but the binary-search result range turns out not to be exactly continuous.
This is the deliberate canary for functions reporting inaccurate monotonicity,
tracked in #90461 (the sibling NaN/
Nullable-key case #98075 was already fixed by#98964).
The message carried no context whatsoever, so every stress-test / fuzzer occurrence
was opaque — there was no way to tell which
KeyCondition, part, or mark rangetriggered it. This PR logs the key condition, the part name, the
relaxedflag, andthe offending mark ranges right before throwing.
The thrown exception message is deliberately kept byte-for-byte unchanged. CI
derives the failure's name from the exception's format string
(
ci/jobs/scripts/log_parser.py), so keeping the message constant preserves theexisting grouping under
Logical error: Inconsistent KeyCondition behavior; thehigh-cardinality details land in
clickhouse-server.err.loginstead, which is acaptured CI artifact.
There is no behavior change in release builds: the branch is compiled out under
NDEBUG, and the suspect range is excluded fromexact_rangesexactly as before(query results are unaffected).
CI report (failing test history) provided in the task:
https://play.clickhouse.com/play?user=play&run=1#V0lUSAogICAgOTAgQVMgaW50ZXJ2YWxfZGF5cwpTRUxFQ1QKICAgIHRvU3RhcnRPZkRheShjaGVja19zdGFydF90aW1lKSBBUyBkYXksCiAgICBjb3VudCgpIEFTIGZhaWx1cmVzLAogICAgZ3JvdXBVbmlxQXJyYXkocHVsbF9yZXF1ZXN0X251bWJlcikgQVMgcHJzLAogICAgYW55KHJlcG9ydF91cmwpIEFTIHJlcG9ydF91cmwKRlJPTSBjaGVja3MKV0hFUkUgKG5vdygpIC0gdG9JbnRlcnZhbERheShpbnRlcnZhbF9kYXlzKSkgPD0gY2hlY2tfc3RhcnRfdGltZQogICAgQU5EIHRlc3RfbmFtZSA9ICdMb2dpY2FsIGVycm9yOiBJbmNvbnNpc3RlbnQgS2V5Q29uZGl0aW9uIGJlaGF2aW9yIChTVElEOiA1MTgyLTJmMjcpJwogICAgLS0gQU5EIGNoZWNrX25hbWUgPSAnU3RyZXNzIHRlc3QgKGFybV9kZWJ1ZyknCiAgICBBTkQgdGVzdF9zdGF0dXMgSU4gKCdGQUlMJywgJ0VSUk9SJykKICAgIEFORCAocHVsbF9yZXF1ZXN0X251bWJlciA9IDAgT1IgYmFzZV9yZWYgSU4gKCdtYXN0ZXInKSkKICAgIEFORCB0ZXN0X2NvbnRleHRfcmF3IExJS0UgJyVFeGNlcHRpb246JScKR1JPVVAgQlkgZGF5Ck9SREVSIEJZIGRheSBERVNDCg==
🤖 Generated with Claude Code
Version info
26.7.1.361(included in26.7and later)