Repository navigation
Fix Field::operator<= comparing a Float64 with itself - #113010
Conversation
The `Float64` branch of `Field::operator<=` read both operands from `*this`, so it compared a value with itself and returned `true` for every `rhs`. `Field::operator>=` is implemented as `rhs <= *this`, so it inherited the same defect. Read the second operand from `rhs`, and pin the ordering of `Float64` fields - including `NaN`, which is ordered after every number and is equal to itself - with unit tests. There are no `Field`-to-`Field` uses of `<=` or `>=` in the codebase today, so no query result can change; this removes a trap for the first caller. Closes: #112778 Caused by: #58959 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Workflow [PR], commit [8c8ec99] Summary: ✅
AI ReviewSummaryThis PR fixes the Final Verdict✅ No new inline findings. The current change looks correct as written. LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 71/71 (100.00%) · Uncovered code |
Address review: pin the `which`-prefix ordering across different Field types and the `UUID` branch of `operator<=` / `operator>=`, which compares `toUnderType()` because `StrongTypedef` has `operator<` but no `operator<=`. Co-Authored-By: Claude Fable 5 <[email protected]>
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=113010&sha=5887e1dcc68fed26b2b3d5126e5ec8c12bcc5fa9&name_0=PR&name_1=Stateless%20tests%20%28arm_asan_ubsan%2C%20targeted%29 and provide a fix in a separate PR. If the fix is already in progress, link it here.
|
|
No fix PR is open yet. This test is mine (added in #107279), the defect is in its oracle, and I am preparing the fix. I will link it here. Your read of the failure mode is right, and the discriminator turns out to be the targeted job's flaky-check target set rather than any diff. On both failing heads the job ran 5 sibling Iceberg tests at 50x each (03565, 03581, 04337, 04545, 04561, so 250 sibling executions). Every passing head had at most 3 siblings at 50x, or fewer. Over 25 days of
04329 is never the flaky-check target itself there; it runs 2 to 16 times as a co-selected test. Two things are wrong here, both mine:
I will validate the fix against the failing condition itself, requiring the current form to fail and the new one to pass on that same state, so it preserves the regression it was written to catch rather than just going green. |
|
Fix PR: #113232 Root cause is in my test, not in this PR. A second defect made it silent rather than diagnosable: The fix clears the cache immediately before each warm-up Your negative local repro was useful: it is consistent with this being residual cache occupancy |
The test needs INSERT analysis to serve a stale schema while the sink force-reads the latest one. It built that by warming the server-global Iceberg metadata files cache and relying on the entry surviving to the INSERT. That cache is SLRU-bounded at 1000 entries and shared with every other test on the server, so a cache left at its bound by earlier tests evicts the entry: the INSERT reads fresh, both views agree, and the rejection correctly does not fire. A second defect made that silent. Both oracles were `grep -oF "INCORRECT_DATA"`, which prints nothing for a successful INSERT and nothing for a different error code, so the reference diff could not distinguish a wrong error code from no error at all, and in the opposite cache state the test passed vacuously. Clear the cache immediately before each warm-up SELECT so the test owns the state it depends on, and report the actual outcome for every outcome (the error code name, or NO_ERROR). The reference file is unchanged, so the rejection must still fire in both scenarios; a run that stops exercising it now fails and names what happened instead of passing. no-parallel is kept, and its comment now states the real reason: the test issues a server-global cache clear, so it must be alone on the server. That is the same pairing 03272_prewarm_mark_cache_add_column.sql uses for the mark cache. Validation: with the cache bound lowered to 40 and pre-filled to 40/40 occupancy (measured via IcebergMetadataFilesCacheFiles), the old form fails with a stdout diff byte-identical to the CI failure and the new form passes on that same injected state. 50/50 randomized runs pass. The only other tests using iceberg_metadata_staleness_ms, 04214 and 04337, are not exposed to residual occupancy and are unchanged. Failed 7 times on Stateless tests (arm_asan_ubsan, targeted) across two unrelated PRs, ClickHouse#113010 and ClickHouse#112866.
|
🕵 The SELECT DISTINCT id FROM merge(currentDatabase(), '^03402_data__fuzz_1$') ORDER BY ALL DESC NULLS FIRST LIMIT true
SETTINGS max_streams_to_max_threads_ratio = 2147483648, max_threads = 4and the mechanism never touches The |
|
🕵 The fix for the unrelated AST fuzzer crash (division by zero via |
Backport #113010 to 26.7: Fix `Field::operator<=` comparing a `Float64` with itself
Backport #113010 to 26.6: Fix `Field::operator<=` comparing a `Float64` with itself
Backport #113010 to 26.5: Fix `Field::operator<=` comparing a `Float64` with itself
… a `Float64` with itself
With `max_threads = 4` and `max_streams_to_max_threads_ratio = 1073741824`, the planner computes `max_streams = 2^32`, and the `UInt32(streams_num)` cast in `ReadFromMerge::createPlanForTable` truncated it to 0. The child `ReadFromMergeTree` then divided by zero in `spreadMarkRangesAmongStreamsWithOrder` (`(info.sum_marks - 1) / num_streams`), crashing debug and sanitizer builds (release builds eliminate the dead division). `IStorage::read` takes `size_t num_streams`, so the cast was a pointless leftover. Found by the AST fuzzer on an unrelated PR: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=113010&sha=59507af89c33f62942e855b50b3e66704cbcf2e9&name_0=PR&name_1=AST%20fuzzer%20%28amd_debug%29 Related PR: ClickHouse#113010 Co-Authored-By: Claude Fable 5 <[email protected]>
… a `Float64` with itself
Closes: #112778
Caused by: #58959
The
Float64branch ofField::operator<=read both operands from*this:Float64 f1 = get<Float64>(); Float64 f2 = get<Float64>(); /// should be rhs.get<Float64>()so it compared a value with itself:
lesswas alwaysfalse,equalswas alwaystrue, and the operator returnedtruefor everyrhs.Field::operator>=is implemented asrhs <= *this, so it inherited the same defect.Field::operator<andField::operator==were already correct, and every other case of the sameswitchusesrhs.get<…>().The fix reads the second operand from
rhs.There are no
Field-to-Fielduses of<=or>=anywhere insrc/,programs/orutils/today - every nearby<=/>=operates on a value already extracted withget<T>orsafeGet<T>- so this cannot change any query result. It removes a trap for whoever adds the first caller.Added unit tests in
src/Core/tests/gtest_field.cpppin the full ordering ofFloat64fields for<,<=,>,>=,==and!=, includingNaNon either or both sides (nan_direction_hintis1, soNaNsorts after every number and is equal to itself).Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Documentation entry for user-facing changes
Version info
26.7.3.17,26.6.3.11,26.5.7.13