Repository navigation
Description
Describe what's wrong
The query condition cache (use_query_condition_cache, default on) keys a granule-skip verdict by a hash of the filter DAG (ActionsDAG::Node::updateHash), which includes the function/type names and constant values but not the session settings that a conversion function captured at build time. FunctionConvertSettings (src/Functions/FunctionsConversion.h) captures precise_float_parsing, cast_string_to_date_time_mode, date_time_overflow_behavior, cast_keep_nullable, etc. from the building session's context, while the function reports a fixed getName() (e.g. toFloat64) and a stable result_type. Two sessions that differ only in one of these settings therefore build byte-identical DAG hashes, collide on the same query condition cache key, and one reuses the other's per-granule verdict — even though the conversion evaluates the predicate to a different value in each session.
The result is silent row loss: a session using a non-default value of one of these settings can mark a granule "no matching rows" in the cache, and a second session running at pure defaults then skips that granule and drops rows that actually match its predicate.
This is a distinct mechanism from #117186 (that one is an omitted DateTime timezone hiding inside the type name). Here the divergence lives inside the FunctionBase object and never reaches getName() or the type name, so a fix scoped to the type-name path does not cover it.
Does it reproduce on the most recent release?
Yes, reproduced on 26.9.1.1.
How to reproduce
precise_float_parsing (default true) is the cleanest lever. A Float64 SQL literal parses to the same bits under both values of the setting, but parsing a String column differs by one ULP for a value like 1.1e-300:
-- literal is identical under both settings (comparison constant is stable across sessions)
SELECT reinterpretAsUInt64(CAST(1.1e-300 AS Float64)) SETTINGS precise_float_parsing=1; -- 119225253609828885
SELECT reinterpretAsUInt64(CAST(1.1e-300 AS Float64)) SETTINGS precise_float_parsing=0; -- 119225253609828885
-- column parse differs by one ULP
SELECT reinterpretAsUInt64(toFloat64(materialize('1.1e-300'))) SETTINGS precise_float_parsing=1; -- 119225253609828885
SELECT reinterpretAsUInt64(toFloat64(materialize('1.1e-300'))) SETTINGS precise_float_parsing=0; -- 119225253609828886Full poisoning on a real server (the query condition cache is disabled in clickhouse local):
CREATE TABLE t (id UInt64, s String) ENGINE = MergeTree ORDER BY id;
INSERT INTO t SELECT number, '1.1e-300' FROM numbers(200000);
-- data is at stake: at pure defaults every row matches
SELECT count() FROM t WHERE toFloat64(s) = 1.1e-300 SETTINGS use_query_condition_cache = 0;
-- 200000
SYSTEM DROP QUERY CONDITION CACHE;
-- session A: one non-default setting, populates the cache (predicate is false under fast parsing)
SELECT count() FROM t WHERE toFloat64(s) = 1.1e-300
SETTINGS use_query_condition_cache = 1, precise_float_parsing = 0;
-- 0 (and system.query_condition_cache now has one entry)
-- session B: PURE DEFAULTS, same query
SELECT count() FROM t WHERE toFloat64(s) = 1.1e-300
SETTINGS use_query_condition_cache = 1;
-- 0 <-- wrongControls, all confirming it is the cache and the rows exist:
-- B alone (no poisoning), defaults, cache on -> correct
SYSTEM DROP QUERY CONDITION CACHE;
SELECT count() FROM t WHERE toFloat64(s) = 1.1e-300 SETTINGS use_query_condition_cache = 1; -- 200000
-- poison, then read B with the cache off -> rows are still there
SYSTEM DROP QUERY CONDITION CACHE;
SELECT count() FROM t WHERE toFloat64(s) = 1.1e-300 SETTINGS use_query_condition_cache = 1, precise_float_parsing = 0; -- 0
SELECT count() FROM t WHERE toFloat64(s) = 1.1e-300 SETTINGS use_query_condition_cache = 0; -- 200000The victim runs at pure defaults; the only non-default input is on the poisoning session, and precise_float_parsing = 0 was itself the default before 26.7, so it is a realistic value to find in an existing user profile on a shared cluster. Any two sessions that disagree on one of the FunctionConvertSettings-captured settings poison each other; precise_float_parsing is used here only because it is the easiest to demonstrate deterministically.
Expected behavior
Session B, running at pure defaults, returns 200000 — every row whose toFloat64(s) equals the literal 1.1e-300 under its own settings. A cache verdict produced by a session that evaluates the predicate differently must not be served to a session with different settings.
Actual behavior
Session B returns 0. It reuses the granule-skip verdict populated by session A (which evaluated the predicate to false under precise_float_parsing = 0) and silently drops all 200000 matching rows. The rows are present (the same query with use_query_condition_cache = 0 returns 200000).
Additional context
Root cause: the cache key ultimately derives from ActionsDAG::Node::updateHash (src/Interpreters/ActionsDAG.cpp), which hashes function_base->getName() / result_type->getName() / constant values but no session settings, while FunctionConvertSettings (src/Functions/FunctionsConversion.h) captures precise_float_parsing, cast_string_to_date_time_mode, date_time_overflow_behavior, and others from context. Folding a fingerprint of the captured settings into the node hash (or reporting these conversions as non-deterministic-across-settings so the cache-population gate excludes them) would close the whole family; the same reasoning applies to FunctionBinaryArithmetic, which captures check_decimal_overflow without surfacing it in getName().
Version info
- Resolved by: Key an expression by the settings a conversion captured #119168
- Merged into:
26.10.1.1515-master(included in26.10and later)
Activity
alexey-milovidov commentedon Aug 31, 2026
Include these settings into the key.
clickgapai commentedon Aug 31, 2026
Reproducer
Results:
master, 26.7, 26.6, 26.5, 26.3, 25.8master, 26.7, 26.6, 26.5, 26.3, 25.826.2reproducesAnalysis metadata
comp-mergetree· SeverityP2· Findingh_issue_117203masterbuildbb113c3849bb(aarch64)comp-query-executionKey an expression by the settings a conversion captured