Repository navigation
Backport #114740 to 26.6: Fix a server crash when merging -OrNull/-OrDefault states under group_by_overflow_mode = 'any' - #115137
Conversation
…Default states under group_by_overflow_mode = 'any'
|
Workflow [BackportPR], commit [4037ef6] Summary: ✅ |
|
@groeneai fix broken test |
|
Root cause is a missing prerequisite on 26.6, not flakiness. Projection The I have no push access to |
|
Correction to my note above: I said this would go in as a pull request into this branch. Three gaps, each hidden behind the one before it, so CI only reported the first:
The result is master's copy minus the two Verified against a 26.6.3.1 debug build:
diff --git a/tests/queries/0_stateless/04896_orfill_merge_group_by_overflow_any.reference b/tests/queries/0_stateless/04896_orfill_merge_group_by_overflow_any.reference
index c3829354d6af4fc..32e65b1a3753364 100644
--- a/tests/queries/0_stateless/04896_orfill_merge_group_by_overflow_any.reference
+++ b/tests/queries/0_stateless/04896_orfill_merge_group_by_overflow_any.reference
@@ -4,10 +4,6 @@ overflow any OrNull
1000 0
overflow any OrDefault
1000 0
-overflow any OrNull(Tuple)
-1000 0
-overflow any Tuple(OrNull)
-1000 0
overflow any two keys
1
1000 0
diff --git a/tests/queries/0_stateless/04896_orfill_merge_group_by_overflow_any.sql b/tests/queries/0_stateless/04896_orfill_merge_group_by_overflow_any.sql
index 7a855b9f64cdb8d..4656186ed59800a 100644
--- a/tests/queries/0_stateless/04896_orfill_merge_group_by_overflow_any.sql
+++ b/tests/queries/0_stateless/04896_orfill_merge_group_by_overflow_any.sql
@@ -7,6 +7,12 @@
-- over the test runner's client-level randomization. force_optimize_projection_name keeps each
-- arm on the aggregate-projection merge path, and the exact surviving-row counts below hold only
-- while both hold, so an arm that stops covering the null place fails instead of passing.
+-- Row-based granules keep a projection's mark count independent of how wide its aggregate states
+-- serialize: adaptive granularity charges an aggregate-state column at its serialized width, so at
+-- a small index_granularity_bytes p reads more marks than the base table and is dropped. Pinning
+-- index_granularity_bytes (not index_granularity, whose lower bound the runner deliberately raises
+-- on slow builds) leaves the granule count driven by rows, so the test stays cheap under sanitizers.
+-- The OrNull arm also names p preferred because p2 answers it over fewer columns.
-- Each oracle counts NULL as a mismatch, because sum() skips NULL rows and a bare s != k
-- therefore stays 0 when a surviving row comes back NULL instead of its aggregate.
-- Merges stay stopped so the three parts below reach the SELECT separately: one projection
@@ -16,9 +22,9 @@
DROP TABLE IF EXISTS t_orfill;
CREATE TABLE t_orfill (k UInt64, k2 UInt64, v UInt64,
- PROJECTION p (SELECT k, sumOrNull(v), sumOrDefault(v), sumTupleOrNull(tuple(v)), sumOrNullTuple(tuple(v)) GROUP BY k),
+ PROJECTION p (SELECT k, sumOrNull(v), sumOrDefault(v) GROUP BY k),
PROJECTION p2 (SELECT k, k2, sumOrNull(v) GROUP BY k, k2))
-ENGINE = MergeTree ORDER BY tuple();
+ENGINE = MergeTree ORDER BY tuple() SETTINGS index_granularity_bytes = 0;
SYSTEM STOP MERGES t_orfill;
@@ -34,7 +40,7 @@ SELECT 'overflow any OrNull';
SELECT count(), sum(s IS NULL OR s != k) FROM (SELECT k, sumOrNull(v) AS s FROM t_orfill GROUP BY k)
SETTINGS optimize_use_projections = 1, max_threads = 1, optimize_aggregation_in_order = 0,
max_rows_to_group_by = 10, group_by_overflow_mode = 'any',
- force_optimize_projection_name = 'p';
+ preferred_optimize_projection_name = 'p', force_optimize_projection_name = 'p';
SELECT 'overflow any OrDefault';
SELECT count(), sum(s IS NULL OR s != k) FROM (SELECT k, sumOrDefault(v) AS s FROM t_orfill GROUP BY k)
@@ -42,22 +48,10 @@ SETTINGS optimize_use_projections = 1, max_threads = 1, optimize_aggregation_in_
max_rows_to_group_by = 10, group_by_overflow_mode = 'any',
force_optimize_projection_name = 'p';
-SELECT 'overflow any OrNull(Tuple)';
-SELECT count(), sum(s.1 IS NULL OR s.1 != k) FROM (SELECT k, sumTupleOrNull(tuple(v)) AS s FROM t_orfill GROUP BY k)
-SETTINGS optimize_use_projections = 1, max_threads = 1, optimize_aggregation_in_order = 0,
- max_rows_to_group_by = 10, group_by_overflow_mode = 'any',
- force_optimize_projection_name = 'p';
-
-SELECT 'overflow any Tuple(OrNull)';
-SELECT count(), sum(s.1 IS NULL OR s.1 != k) FROM (SELECT k, sumOrNullTuple(tuple(v)) AS s FROM t_orfill GROUP BY k)
-SETTINGS optimize_use_projections = 1, max_threads = 1, optimize_aggregation_in_order = 0,
- max_rows_to_group_by = 10, group_by_overflow_mode = 'any',
- force_optimize_projection_name = 'p';
-
SELECT 'overflow any two keys';
-- k2 is a stored column, not an expression over k, so optimize_group_by_function_keys cannot
-- drop it and the aggregation really uses the fixed-keys (keys128) method.
-SELECT count() > 0 FROM (EXPLAIN SELECT k, k2, sumOrNull(v) FROM t_orfill GROUP BY k, k2)
+SELECT count() > 0 FROM (EXPLAIN actions = 1, pretty = 1 SELECT k, k2, sumOrNull(v) FROM t_orfill GROUP BY k, k2)
WHERE explain ILIKE '%Keys: k, k2%';
SELECT count(), sum(s IS NULL OR s != k) FROM (SELECT k, k2, sumOrNull(v) AS s FROM t_orfill GROUP BY k, k2)
SETTINGS optimize_use_projections = 1, max_threads = 1, optimize_aggregation_in_order = 0, |
|
Hi @fm4v, gentle ping - any update on the 04896 patch above? It needs someone with push access to |
…plain_query_plan_default) Co-authored-by: nickitat <[email protected]>
Applied @groeneai's patch in 4037ef6: dropped the two |
|
|
|
Thanks @nickitat. That validation was on a real 26.6.3 build: the file completes with output byte-identical to its Why the patch also touches |
Original pull-request #114740
This pull-request is a last step of an automated backporting.
Treat it as a standard pull-request: look at the checks and resolve conflicts.
Merge it only if you intend to backport changes to the target branch, otherwise just close it.
The PR source
The PR is created in the CI job
Version info
26.6.5.31