From 8b26fea83572cf5c043721b7835c3828937f9c27 Mon Sep 17 00:00:00 2001 From: Galina Shalygina Date: Thu, 10 May 2018 23:01:41 +0200 Subject: [PATCH 01/33] MDEV-16088: Pushdown into materialized views/derived tables doesn't work in the IN subqueries The pushdown into the materialized derived table/view wasn't done because optimize() for the derived was called before any conditions that can be pushed down were extracted. So optimize() in convert_join_subqueries_to_semijoins() method is called too early and is unnecessary. The second optimize() call in mysql_handle_single_derived() is enough. --- mysql-test/r/derived_cond_pushdown.result | 413 ++++++++++++++++++++++ mysql-test/r/derived_view.result | 4 +- mysql-test/r/subselect_extra.result | 4 +- mysql-test/t/derived_cond_pushdown.test | 83 +++++ sql/opt_subselect.cc | 2 - 5 files changed, 500 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/derived_cond_pushdown.result b/mysql-test/r/derived_cond_pushdown.result index 8e74e093a4a..09b3b52b701 100644 --- a/mysql-test/r/derived_cond_pushdown.result +++ b/mysql-test/r/derived_cond_pushdown.result @@ -9045,3 +9045,416 @@ select * from (select date('2018-01-01') as d) as t where t.d between date ('2017-01-01') and date ('2019-01-01'); d 2018-01-01 +# +# MDEV-16088: pushdown into derived defined in the IN subquery +# +CREATE TABLE t1 (a INT, b INT); +CREATE TABLE t2 (e INT, f INT, g INT); +INSERT INTO t1 VALUES (1,14),(2,13),(1,19),(2,32),(3,24); +INSERT INTO t2 VALUES (1,19,2),(3,24,1),(1,12,2),(3,11,3),(2,32,1); +SELECT * FROM t1 +WHERE (t1.a,t1.b) IN +( +SELECT d_tab.e,d_tab.max_f +FROM ( +SELECT t2.e, MAX(t2.f) AS max_f +FROM t2 +GROUP BY t2.e +HAVING max_f>18 +) as d_tab +WHERE d_tab.e>1 +) +; +a b +2 32 +3 24 +EXPLAIN SELECT * FROM t1 +WHERE (t1.a,t1.b) IN +( +SELECT d_tab.e,d_tab.max_f +FROM ( +SELECT t2.e, MAX(t2.f) AS max_f +FROM t2 +GROUP BY t2.e +HAVING max_f>18 +) as d_tab +WHERE d_tab.e>1 +) +; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 +1 PRIMARY eq_ref distinct_key distinct_key 8 func,func 1 +2 MATERIALIZED ALL NULL NULL NULL NULL 5 Using where +3 DERIVED t2 ALL NULL NULL NULL NULL 5 Using where; Using temporary; Using filesort +EXPLAIN FORMAT=JSON SELECT * FROM t1 +WHERE (t1.a,t1.b) IN +( +SELECT d_tab.e,d_tab.max_f +FROM ( +SELECT t2.e, MAX(t2.f) AS max_f +FROM t2 +GROUP BY t2.e +HAVING max_f>18 +) as d_tab +WHERE d_tab.e>1 +) +; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100 + }, + "table": { + "table_name": "", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "8", + "used_key_parts": ["e", "max_f"], + "ref": ["func", "func"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "table": { + "table_name": "", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "d_tab.e > 1", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "max_f > 18", + "filesort": { + "sort_key": "t2.e", + "temporary_table": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t2.e > 1" + } + } + } + } + } + } + } + } + } + } +} +SELECT * FROM t1 +WHERE (t1.a,t1.b) IN +( +SELECT d_tab.e,d_tab.max_f +FROM ( +SELECT t2.e, MAX(t2.f) AS max_f +FROM t2 +GROUP BY t2.e +HAVING max_f>18 +) as d_tab +WHERE d_tab.max_f<25 +) +; +a b +1 19 +3 24 +EXPLAIN SELECT * FROM t1 +WHERE (t1.a,t1.b) IN +( +SELECT d_tab.e,d_tab.max_f +FROM ( +SELECT t2.e, MAX(t2.f) AS max_f +FROM t2 +GROUP BY t2.e +HAVING max_f>18 +) as d_tab +WHERE d_tab.max_f<25 +) +; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 +1 PRIMARY eq_ref distinct_key distinct_key 8 func,func 1 +2 MATERIALIZED ALL NULL NULL NULL NULL 5 Using where +3 DERIVED t2 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort +EXPLAIN FORMAT=JSON SELECT * FROM t1 +WHERE (t1.a,t1.b) IN +( +SELECT d_tab.e,d_tab.max_f +FROM ( +SELECT t2.e, MAX(t2.f) AS max_f +FROM t2 +GROUP BY t2.e +HAVING max_f>18 +) as d_tab +WHERE d_tab.max_f<25 +) +; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100 + }, + "table": { + "table_name": "", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "8", + "used_key_parts": ["e", "max_f"], + "ref": ["func", "func"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "table": { + "table_name": "", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "d_tab.max_f < 25", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "max_f > 18 and max_f < 25", + "filesort": { + "sort_key": "t2.e", + "temporary_table": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 5, + "filtered": 100 + } + } + } + } + } + } + } + } + } + } +} +SELECT * FROM t1 +WHERE (t1.a,t1.b) IN +( +SELECT d_tab.e, MAX(d_tab.max_f) AS max_f +FROM ( +SELECT t2.e, MAX(t2.f) as max_f, t2.g +FROM t2 +GROUP BY t2.e +) as d_tab +WHERE d_tab.e>1 +GROUP BY d_tab.g +) +; +a b +2 32 +EXPLAIN SELECT * FROM t1 +WHERE (t1.a,t1.b) IN +( +SELECT d_tab.e, MAX(d_tab.max_f) AS max_f +FROM ( +SELECT t2.e, MAX(t2.f) as max_f, t2.g +FROM t2 +GROUP BY t2.e +) as d_tab +WHERE d_tab.e>1 +GROUP BY d_tab.g +) +; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where +1 PRIMARY eq_ref distinct_key distinct_key 8 test.t1.a,test.t1.b 1 +2 MATERIALIZED ALL NULL NULL NULL NULL 5 Using where; Using temporary +3 DERIVED t2 ALL NULL NULL NULL NULL 5 Using where; Using temporary; Using filesort +EXPLAIN FORMAT=JSON SELECT * FROM t1 +WHERE (t1.a,t1.b) IN +( +SELECT d_tab.e, MAX(d_tab.max_f) AS max_f +FROM ( +SELECT t2.e, MAX(t2.f) as max_f, t2.g +FROM t2 +GROUP BY t2.e +) as d_tab +WHERE d_tab.e>1 +GROUP BY d_tab.g +) +; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a is not null and t1.b is not null" + }, + "table": { + "table_name": "", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "8", + "used_key_parts": ["e", "max_f"], + "ref": ["test.t1.a", "test.t1.b"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "temporary_table": { + "table": { + "table_name": "", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "d_tab.e > 1", + "materialized": { + "query_block": { + "select_id": 3, + "filesort": { + "sort_key": "t2.e", + "temporary_table": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t2.e > 1" + } + } + } + } + } + } + } + } + } + } + } +} +SELECT * FROM t1 +WHERE (t1.a,t1.b) IN +( +SELECT d_tab.e, MAX(d_tab.max_f) AS max_f +FROM ( +SELECT t2.e, MAX(t2.f) as max_f, t2.g +FROM t2 +GROUP BY t2.e +) as d_tab +WHERE d_tab.max_f>20 +GROUP BY d_tab.g +) +; +a b +2 32 +EXPLAIN SELECT * FROM t1 +WHERE (t1.a,t1.b) IN +( +SELECT d_tab.e, MAX(d_tab.max_f) AS max_f +FROM ( +SELECT t2.e, MAX(t2.f) as max_f, t2.g +FROM t2 +GROUP BY t2.e +) as d_tab +WHERE d_tab.max_f>20 +GROUP BY d_tab.g +) +; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where +1 PRIMARY eq_ref distinct_key distinct_key 8 test.t1.a,test.t1.b 1 +2 MATERIALIZED ALL NULL NULL NULL NULL 5 Using where; Using temporary +3 DERIVED t2 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort +EXPLAIN FORMAT=JSON SELECT * FROM t1 +WHERE (t1.a,t1.b) IN +( +SELECT d_tab.e, MAX(d_tab.max_f) AS max_f +FROM ( +SELECT t2.e, MAX(t2.f) as max_f, t2.g +FROM t2 +GROUP BY t2.e +) as d_tab +WHERE d_tab.max_f>20 +GROUP BY d_tab.g +) +; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "t1.a is not null and t1.b is not null" + }, + "table": { + "table_name": "", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "8", + "used_key_parts": ["e", "max_f"], + "ref": ["test.t1.a", "test.t1.b"], + "rows": 1, + "filtered": 100, + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "temporary_table": { + "table": { + "table_name": "", + "access_type": "ALL", + "rows": 5, + "filtered": 100, + "attached_condition": "d_tab.max_f > 20", + "materialized": { + "query_block": { + "select_id": 3, + "having_condition": "max_f > 20", + "filesort": { + "sort_key": "t2.e", + "temporary_table": { + "table": { + "table_name": "t2", + "access_type": "ALL", + "rows": 5, + "filtered": 100 + } + } + } + } + } + } + } + } + } + } + } +} +DROP TABLE t1,t2; diff --git a/mysql-test/r/derived_view.result b/mysql-test/r/derived_view.result index df6ba084a87..d2804ce2329 100644 --- a/mysql-test/r/derived_view.result +++ b/mysql-test/r/derived_view.result @@ -1841,7 +1841,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 system NULL NULL NULL NULL 1 1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where 1 PRIMARY ALL NULL NULL NULL NULL 3 Using where; Start temporary; End temporary -3 DERIVED t1 ALL NULL NULL NULL NULL 3 +3 DERIVED t1 ALL NULL NULL NULL NULL 3 Using where SELECT * FROM t3 WHERE t3.b IN (SELECT v1.b FROM v1, t2 WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c); @@ -1856,7 +1856,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 system NULL NULL NULL NULL 1 1 PRIMARY ref key1 key1 8 const,const 0 Start temporary 1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (flat, BNL join) -3 DERIVED t1 ALL NULL NULL NULL NULL 3 +3 DERIVED t1 ALL NULL NULL NULL NULL 3 Using where SELECT * FROM t3 WHERE t3.b IN (SELECT v1.b FROM v1, t2 WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c); diff --git a/mysql-test/r/subselect_extra.result b/mysql-test/r/subselect_extra.result index 73642c09324..a3a0f1f9a15 100644 --- a/mysql-test/r/subselect_extra.result +++ b/mysql-test/r/subselect_extra.result @@ -434,7 +434,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 system NULL NULL NULL NULL 1 1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where 1 PRIMARY ALL NULL NULL NULL NULL 3 Using where; FirstMatch(t3); Using join buffer (flat, BNL join) -3 DERIVED t1 ALL NULL NULL NULL NULL 3 +3 DERIVED t1 ALL NULL NULL NULL NULL 3 Using where SELECT * FROM t3 WHERE t3.b IN (SELECT v1.b FROM v1, t2 WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c); @@ -449,7 +449,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 system NULL NULL NULL NULL 1 1 PRIMARY ref key1 key1 8 const,const 0 Start temporary 1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (flat, BNL join) -3 DERIVED t1 ALL NULL NULL NULL NULL 3 +3 DERIVED t1 ALL NULL NULL NULL NULL 3 Using where SELECT * FROM t3 WHERE t3.b IN (SELECT v1.b FROM v1, t2 WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c); diff --git a/mysql-test/t/derived_cond_pushdown.test b/mysql-test/t/derived_cond_pushdown.test index 0b87738a727..e8f6e9c11f9 100644 --- a/mysql-test/t/derived_cond_pushdown.test +++ b/mysql-test/t/derived_cond_pushdown.test @@ -1646,3 +1646,86 @@ select * from (select date('2018-01-01') as d select * from (select date('2018-01-01') as d) as t where t.d between date ('2017-01-01') and date ('2019-01-01'); + +--echo # +--echo # MDEV-16088: pushdown into derived defined in the IN subquery +--echo # + +CREATE TABLE t1 (a INT, b INT); +CREATE TABLE t2 (e INT, f INT, g INT); +INSERT INTO t1 VALUES (1,14),(2,13),(1,19),(2,32),(3,24); +INSERT INTO t2 VALUES (1,19,2),(3,24,1),(1,12,2),(3,11,3),(2,32,1); + +LET $query= +SELECT * FROM t1 +WHERE (t1.a,t1.b) IN + ( + SELECT d_tab.e,d_tab.max_f + FROM ( + SELECT t2.e, MAX(t2.f) AS max_f + FROM t2 + GROUP BY t2.e + HAVING max_f>18 + ) as d_tab + WHERE d_tab.e>1 + ) +; +EVAL $query; +EVAL EXPLAIN $query; +EVAL EXPLAIN FORMAT=JSON $query; + +LET $query= +SELECT * FROM t1 +WHERE (t1.a,t1.b) IN + ( + SELECT d_tab.e,d_tab.max_f + FROM ( + SELECT t2.e, MAX(t2.f) AS max_f + FROM t2 + GROUP BY t2.e + HAVING max_f>18 + ) as d_tab + WHERE d_tab.max_f<25 + ) +; +EVAL $query; +EVAL EXPLAIN $query; +EVAL EXPLAIN FORMAT=JSON $query; + +LET $query= +SELECT * FROM t1 +WHERE (t1.a,t1.b) IN + ( + SELECT d_tab.e, MAX(d_tab.max_f) AS max_f + FROM ( + SELECT t2.e, MAX(t2.f) as max_f, t2.g + FROM t2 + GROUP BY t2.e + ) as d_tab + WHERE d_tab.e>1 + GROUP BY d_tab.g + ) +; +EVAL $query; +EVAL EXPLAIN $query; +EVAL EXPLAIN FORMAT=JSON $query; + +LET $query= +SELECT * FROM t1 +WHERE (t1.a,t1.b) IN + ( + SELECT d_tab.e, MAX(d_tab.max_f) AS max_f + FROM ( + SELECT t2.e, MAX(t2.f) as max_f, t2.g + FROM t2 + GROUP BY t2.e + ) as d_tab + WHERE d_tab.max_f>20 + GROUP BY d_tab.g + ) +; +EVAL $query; +EVAL EXPLAIN $query; +EVAL EXPLAIN FORMAT=JSON $query; + +DROP TABLE t1,t2; diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index 7b081218dea..90416e691d4 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -1092,8 +1092,6 @@ bool convert_join_subqueries_to_semijoins(JOIN *join) while ((in_subq= li++)) { SELECT_LEX *subq_sel= in_subq->get_select_lex(); - if (subq_sel->handle_derived(thd->lex, DT_OPTIMIZE)) - DBUG_RETURN(1); if (subq_sel->handle_derived(thd->lex, DT_MERGE)) DBUG_RETURN(TRUE); subq_sel->update_used_tables(); From 6c0f3dd3414a97266912651fb169f630a36f2659 Mon Sep 17 00:00:00 2001 From: Galina Shalygina Date: Sat, 12 May 2018 20:32:16 +0200 Subject: [PATCH 02/33] MDEV-16090: Server crash in in Item_func_in::val_int or assertion `in_item' failure upon SELECT with impossible condition The problem appears because of a wrong implementation of the Item_func_in::build_clone() method. It didn't clone 'array' and 'cmp_fields' fields for the cloned IN predicate and this could cause crashes. The Item_func_in::fix_length_and_dec() method was refactored and a new method named Item_func_in::create_array() was created. It allowed to create 'array' for cloned IN predicates in a proper way. --- mysql-test/r/derived_cond_pushdown.result | 15 +++ mysql-test/t/derived_cond_pushdown.test | 16 +++ sql/item_cmpfunc.cc | 121 ++++++++++++++-------- sql/item_cmpfunc.h | 13 +-- sql/table.cc | 4 +- 5 files changed, 111 insertions(+), 58 deletions(-) diff --git a/mysql-test/r/derived_cond_pushdown.result b/mysql-test/r/derived_cond_pushdown.result index 09b3b52b701..3fbc81019cc 100644 --- a/mysql-test/r/derived_cond_pushdown.result +++ b/mysql-test/r/derived_cond_pushdown.result @@ -9458,3 +9458,18 @@ EXPLAIN } } DROP TABLE t1,t2; +# +# MDEV-15765: pushing condition with IN subquery defined with constants +# using substitution +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +SELECT * FROM +( +SELECT DISTINCT * FROM t1 +) der_tab +WHERE (a>0 AND a<2 OR a IN (2,3)) AND +(a=2 OR 0); +a +2 +DROP TABLE t1; diff --git a/mysql-test/t/derived_cond_pushdown.test b/mysql-test/t/derived_cond_pushdown.test index e8f6e9c11f9..d3832ce1ec3 100644 --- a/mysql-test/t/derived_cond_pushdown.test +++ b/mysql-test/t/derived_cond_pushdown.test @@ -1729,3 +1729,19 @@ EVAL EXPLAIN $query; EVAL EXPLAIN FORMAT=JSON $query; DROP TABLE t1,t2; + +--echo # +--echo # MDEV-15765: pushing condition with IN subquery defined with constants +--echo # using substitution +--echo # + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +SELECT * FROM +( + SELECT DISTINCT * FROM t1 +) der_tab +WHERE (a>0 AND a<2 OR a IN (2,3)) AND + (a=2 OR 0); + +DROP TABLE t1; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 72a4d99c968..f552a3eca58 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -4117,6 +4117,67 @@ static int srtcmp_in(CHARSET_INFO *cs, const String *x,const String *y) (uchar *) y->ptr(),y->length()); } + +/* + Create 'array' for this IN predicate with the respect to its result type + and put values from in 'array'. +*/ + +bool Item_func_in::create_array(THD *thd) +{ + Item *date_arg= 0; + + switch (m_compare_type) { + case STRING_RESULT: + array=new (thd->mem_root) in_string(thd, arg_count - 1, + (qsort2_cmp) srtcmp_in, + cmp_collation.collation); + break; + case INT_RESULT: + array= new (thd->mem_root) in_longlong(thd, arg_count - 1); + break; + case REAL_RESULT: + array= new (thd->mem_root) in_double(thd, arg_count - 1); + break; + case ROW_RESULT: + /* + The row comparator was created at the beginning but only DATETIME + items comparators were initialized. Call store_value() to setup + others. + */ + ((in_row*)array)->tmp.store_value(args[0]); + break; + case DECIMAL_RESULT: + array= new (thd->mem_root) in_decimal(thd, arg_count - 1); + break; + case TIME_RESULT: + date_arg= find_date_time_item(thd, args, arg_count, 0, true); + array= new (thd->mem_root) in_datetime(thd, date_arg, arg_count - 1); + break; + } + if (!array || thd->is_fatal_error) // OOM + return true; + uint j=0; + for (uint i=1 ; i < arg_count ; i++) + { + array->set(j,args[i]); + if (!args[i]->null_value) + j++; // include this cell in the array. + else + { + /* + We don't put NULL values in array to avoid erronous matches in + bisection. + */ + have_null= 1; + } + } + if ((array->used_count= j)) + array->sort(); + return false; +} + + void Item_func_in::fix_length_and_dec() { Item **arg, **arg_end; @@ -4244,53 +4305,8 @@ void Item_func_in::fix_length_and_dec() m_compare_type= INT_RESULT; } } - switch (m_compare_type) { - case STRING_RESULT: - array=new (thd->mem_root) in_string(thd, arg_count - 1, - (qsort2_cmp) srtcmp_in, - cmp_collation.collation); - break; - case INT_RESULT: - array= new (thd->mem_root) in_longlong(thd, arg_count - 1); - break; - case REAL_RESULT: - array= new (thd->mem_root) in_double(thd, arg_count - 1); - break; - case ROW_RESULT: - /* - The row comparator was created at the beginning but only DATETIME - items comparators were initialized. Call store_value() to setup - others. - */ - ((in_row*)array)->tmp.store_value(args[0]); - break; - case DECIMAL_RESULT: - array= new (thd->mem_root) in_decimal(thd, arg_count - 1); - break; - case TIME_RESULT: - date_arg= find_date_time_item(thd, args, arg_count, 0, true); - array= new (thd->mem_root) in_datetime(thd, date_arg, arg_count - 1); - break; - } - if (!array || thd->is_fatal_error) // OOM + if (create_array(thd)) return; - uint j=0; - for (uint i=1 ; i < arg_count ; i++) - { - array->set(j,args[i]); - if (!args[i]->null_value) - j++; // include this cell in the array. - else - { - /* - We don't put NULL values in array, to avoid erronous matches in - bisection. - */ - have_null= 1; - } - } - if ((array->used_count= j)) - array->sort(); } else { @@ -4399,6 +4415,19 @@ longlong Item_func_in::val_int() } +Item *Item_func_in::build_clone(THD *thd, MEM_ROOT *mem_root) +{ + Item_func_in *clone= (Item_func_in *) Item_func::build_clone(thd, mem_root); + if (clone) + { + if (array && clone->create_array(thd)) + return NULL; + memcpy(&clone->cmp_items, &cmp_items, sizeof(cmp_items)); + } + return clone; +} + + longlong Item_func_bit_or::val_int() { DBUG_ASSERT(fixed == 1); diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index de1b27cff1a..78a9e384b55 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -1648,6 +1648,7 @@ public: } longlong val_int(); bool fix_fields(THD *, Item **); + bool create_array(THD *thd); void fix_length_and_dec(); void cleanup() { @@ -1693,16 +1694,7 @@ public: bool count_sargable_conds(void *arg); Item *get_copy(THD *thd, MEM_ROOT *mem_root) { return get_item_copy(thd, mem_root, this); } - Item *build_clone(THD *thd, MEM_ROOT *mem_root) - { - Item_func_in *clone= (Item_func_in *) Item_func::build_clone(thd, mem_root); - if (clone) - { - clone->array= 0; - bzero(&clone->cmp_items, sizeof(cmp_items)); - } - return clone; - } + Item *build_clone(THD *thd, MEM_ROOT *mem_root); }; class cmp_item_row :public cmp_item @@ -1731,6 +1723,7 @@ public: ~in_row(); void set(uint pos,Item *item); uchar *get_value(Item *item); + friend bool Item_func_in::create_array(THD *thd); friend void Item_func_in::fix_length_and_dec(); Item_result result_type() { return ROW_RESULT; } cmp_item *get_cmp_item() { return &tmp; } diff --git a/sql/table.cc b/sql/table.cc index 4e242e3f12e..fff2be4f154 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -8241,8 +8241,8 @@ Item* TABLE_LIST::build_pushable_cond_for_table(THD *thd, Item *cond) new_cond->argument_list()->push_back(fix, thd->mem_root); } - if (is_fix_needed) - new_cond->fix_fields(thd, 0); + if (is_fix_needed && new_cond->fix_fields(thd, 0)) + return 0; switch (new_cond->argument_list()->elements) { From 7e7592ade5bec98e80fb9a4aa6f6ad75107b605f Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Mon, 14 May 2018 15:59:51 +0300 Subject: [PATCH 03/33] MDEV-16154: Server crashes in in myrocks::ha_rocksdb::load_auto_incr_value_from_index Backport the fix from the upstream and add our testcase. Backported cset: commit 997a979bf5e2f75ab88781d9d3fd22dddc1fc21f Author: Manuel Ung Date: Thu Feb 15 08:38:12 2018 -0800 Fix crashes in autoincrement code paths Summary: There are two issues related to autoincrement that can lead to crashes: 1. The max value for double/float type for autoincrement was not implemented in MyRocks, and can lead to assertions. The fix is to add them in. 2. If we try to set auto_increment via alter table on a table without an auto_increment column defined, we segfault because there is no index from which to read the last value. The fix is to perform a check to see if autoincrement exists before reading from index (similar to code ha_rocksdb::open). Fixes https://github.com/facebook/mysql-5.6/issues/792 Closes https://github.com/facebook/mysql-5.6/pull/794 Differential Revision: D6995096 Pulled By: lth fbshipit-source-id: 1130ce1 --- storage/rocksdb/ha_rocksdb.cc | 10 +++++++++- .../mysql-test/rocksdb/r/autoinc_vars.result | 10 ++++++++++ .../mysql-test/rocksdb/r/mariadb_port_fixes.result | 7 +++++++ .../rocksdb/mysql-test/rocksdb/t/autoinc_vars.test | 13 +++++++++++++ .../mysql-test/rocksdb/t/mariadb_port_fixes.test | 9 +++++++++ 5 files changed, 48 insertions(+), 1 deletion(-) diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc index 46d963860a2..8d7809a2213 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -5088,6 +5088,12 @@ static ulonglong rdb_get_int_col_max_value(const Field *field) { case HA_KEYTYPE_LONGLONG: max_value = 0x7FFFFFFFFFFFFFFFULL; break; + case HA_KEYTYPE_FLOAT: + max_value = 0x1000000ULL; + break; + case HA_KEYTYPE_DOUBLE: + max_value = 0x20000000000000ULL; + break; default: abort(); } @@ -11734,7 +11740,9 @@ bool ha_rocksdb::prepare_inplace_alter_table( if (!new_tdef) { new_tdef = m_tbl_def; } - max_auto_incr = load_auto_incr_value_from_index(); + if (table->found_next_number_field) { + max_auto_incr = load_auto_incr_value_from_index(); + } } ha_alter_info->handler_ctx = new Rdb_inplace_alter_ctx( diff --git a/storage/rocksdb/mysql-test/rocksdb/r/autoinc_vars.result b/storage/rocksdb/mysql-test/rocksdb/r/autoinc_vars.result index 5da9a7e7e1c..8cc9b070a70 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/autoinc_vars.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/autoinc_vars.result @@ -140,3 +140,13 @@ SELECT * FROM t1; a b 18446744073709551613 a DROP TABLE t1; +#---------------------------------- +# Issue #792 Crash in autoincrement +#---------------------------------- +CREATE TABLE t1(C1 DOUBLE AUTO_INCREMENT KEY,C2 CHAR) ENGINE=ROCKSDB; +INSERT INTO t1 VALUES(2177,0); +DROP TABLE t1; +CREATE TABLE t0(c0 BLOB) ENGINE=ROCKSDB; +INSERT INTO t0 VALUES(0); +ALTER TABLE t0 AUTO_INCREMENT=0; +DROP TABLE t0; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/mariadb_port_fixes.result b/storage/rocksdb/mysql-test/rocksdb/r/mariadb_port_fixes.result index 98c5ebe9f4c..eeb261d22e7 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/mariadb_port_fixes.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/mariadb_port_fixes.result @@ -89,3 +89,10 @@ CREATE TABLE t1 (i INT) ENGINE=RocksDB; FLUSH TABLE t1 FOR EXPORT; ERROR HY000: Storage engine ROCKSDB of the table `test`.`t1` doesn't have this option DROP TABLE t1; +# +# MDEV-16154 Server crashes in in myrocks::ha_rocksdb::load_auto_incr_value_from_inde +# +CREATE TABLE t1 (a INT) ENGINE=RocksDB; +INSERT INTO t1 VALUES (1); +ALTER TABLE t1 AUTO_INCREMENT 10; +DROP TABLE t1; diff --git a/storage/rocksdb/mysql-test/rocksdb/t/autoinc_vars.test b/storage/rocksdb/mysql-test/rocksdb/t/autoinc_vars.test index b8968590155..9d7f0365d07 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/autoinc_vars.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/autoinc_vars.test @@ -103,3 +103,16 @@ SHOW CREATE TABLE t1; INSERT INTO t1 VALUES (NULL, 'c'); SELECT * FROM t1; DROP TABLE t1; + +--echo #---------------------------------- +--echo # Issue #792 Crash in autoincrement +--echo #---------------------------------- + +CREATE TABLE t1(C1 DOUBLE AUTO_INCREMENT KEY,C2 CHAR) ENGINE=ROCKSDB; +INSERT INTO t1 VALUES(2177,0); +DROP TABLE t1; + +CREATE TABLE t0(c0 BLOB) ENGINE=ROCKSDB; +INSERT INTO t0 VALUES(0); +ALTER TABLE t0 AUTO_INCREMENT=0; +DROP TABLE t0; diff --git a/storage/rocksdb/mysql-test/rocksdb/t/mariadb_port_fixes.test b/storage/rocksdb/mysql-test/rocksdb/t/mariadb_port_fixes.test index 681e3d2d63f..a48c8a5e426 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/mariadb_port_fixes.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/mariadb_port_fixes.test @@ -83,3 +83,12 @@ CREATE TABLE t1 (i INT) ENGINE=RocksDB; FLUSH TABLE t1 FOR EXPORT; DROP TABLE t1; +--echo # +--echo # MDEV-16154 Server crashes in in myrocks::ha_rocksdb::load_auto_incr_value_from_inde +--echo # +CREATE TABLE t1 (a INT) ENGINE=RocksDB; +INSERT INTO t1 VALUES (1); +ALTER TABLE t1 AUTO_INCREMENT 10; + +DROP TABLE t1; + From 16a8a241c297a4ae683523e68518aa85a129daea Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Mon, 14 May 2018 17:57:33 +0300 Subject: [PATCH 04/33] MDEV-14375: rocksdb.bulk_load_unsorted fails Down-scale the test by a factor of 2. --- .../rocksdb/include/bulk_load_unsorted.inc | 11 ++-- .../rocksdb/r/bulk_load_unsorted.result | 51 ++++++++----------- .../rocksdb/r/bulk_load_unsorted_rev.result | 51 ++++++++----------- 3 files changed, 46 insertions(+), 67 deletions(-) diff --git a/storage/rocksdb/mysql-test/rocksdb/include/bulk_load_unsorted.inc b/storage/rocksdb/mysql-test/rocksdb/include/bulk_load_unsorted.inc index 151ec0ccf14..5f808087e3e 100644 --- a/storage/rocksdb/mysql-test/rocksdb/include/bulk_load_unsorted.inc +++ b/storage/rocksdb/mysql-test/rocksdb/include/bulk_load_unsorted.inc @@ -84,7 +84,7 @@ perl; my $fn = $ENV{'ROCKSDB_INFILE'}; open(my $fh, '>', $fn) || die "perl open($fn): $!"; binmode $fh; -my $max = 5000000; +my $max = 2500000; my $sign = 1; for (my $ii = 0; $ii < $max; $ii++) { @@ -129,12 +129,9 @@ ANALYZE TABLE t1, t2, t3; SHOW TABLE STATUS WHERE name LIKE 't%'; # Make sure all the data is there. -select count(a) from t1; -select count(b) from t1; -select count(a) from t2; -select count(b) from t2; -select count(a) from t3; -select count(b) from t3; +select count(a),count(b) from t1; +select count(a),count(b) from t2; +select count(a),count(b) from t3; SELECT * FROM t1 FORCE INDEX (PRIMARY) LIMIT 3; SELECT * FROM t2 FORCE INDEX (PRIMARY) LIMIT 3; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_unsorted.result b/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_unsorted.result index 2adaba1e228..40274c337c3 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_unsorted.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_unsorted.result @@ -75,9 +75,9 @@ LOAD DATA INFILE INTO TABLE t3; set rocksdb_bulk_load=0; SHOW TABLE STATUS WHERE name LIKE 't%'; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned +t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL +t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL +t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned ANALYZE TABLE t1, t2, t3; Table Op Msg_type Msg_text test.t1 analyze status OK @@ -85,36 +85,27 @@ test.t2 analyze status OK test.t3 analyze status OK SHOW TABLE STATUS WHERE name LIKE 't%'; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned -select count(a) from t1; -count(a) -5000000 -select count(b) from t1; -count(b) -5000000 -select count(a) from t2; -count(a) -5000000 -select count(b) from t2; -count(b) -5000000 -select count(a) from t3; -count(a) -5000000 -select count(b) from t3; -count(b) -5000000 +t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL +t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL +t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned +select count(a),count(b) from t1; +count(a) count(b) +2500000 2500000 +select count(a),count(b) from t2; +count(a) count(b) +2500000 2500000 +select count(a),count(b) from t3; +count(a) count(b) +2500000 2500000 SELECT * FROM t1 FORCE INDEX (PRIMARY) LIMIT 3; a b --4999998 5000000 --4999996 4999998 --4999994 4999996 +-2499998 2500000 +-2499996 2499998 +-2499994 2499996 SELECT * FROM t2 FORCE INDEX (PRIMARY) LIMIT 3; a b -4999999 -4999997 -4999997 -4999995 -4999995 -4999993 +2499999 -2499997 +2499997 -2499995 +2499995 -2499993 disconnect other; DROP TABLE t1, t2, t3; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_unsorted_rev.result b/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_unsorted_rev.result index f828fa57255..1aaac8ec268 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_unsorted_rev.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_unsorted_rev.result @@ -75,9 +75,9 @@ LOAD DATA INFILE INTO TABLE t3; set rocksdb_bulk_load=0; SHOW TABLE STATUS WHERE name LIKE 't%'; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned +t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL +t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL +t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned ANALYZE TABLE t1, t2, t3; Table Op Msg_type Msg_text test.t1 analyze status OK @@ -85,36 +85,27 @@ test.t2 analyze status OK test.t3 analyze status OK SHOW TABLE STATUS WHERE name LIKE 't%'; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned -select count(a) from t1; -count(a) -5000000 -select count(b) from t1; -count(b) -5000000 -select count(a) from t2; -count(a) -5000000 -select count(b) from t2; -count(b) -5000000 -select count(a) from t3; -count(a) -5000000 -select count(b) from t3; -count(b) -5000000 +t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL +t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL +t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned +select count(a),count(b) from t1; +count(a) count(b) +2500000 2500000 +select count(a),count(b) from t2; +count(a) count(b) +2500000 2500000 +select count(a),count(b) from t3; +count(a) count(b) +2500000 2500000 SELECT * FROM t1 FORCE INDEX (PRIMARY) LIMIT 3; a b -4999999 -4999997 -4999997 -4999995 -4999995 -4999993 +2499999 -2499997 +2499997 -2499995 +2499995 -2499993 SELECT * FROM t2 FORCE INDEX (PRIMARY) LIMIT 3; a b --4999998 5000000 --4999996 4999998 --4999994 4999996 +-2499998 2500000 +-2499996 2499998 +-2499994 2499996 disconnect other; DROP TABLE t1, t2, t3; From fb5d5794623af1e6bff2ba7f6c7142770fa5e9d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 14 May 2018 18:04:25 +0300 Subject: [PATCH 05/33] MDEV-13987 Hang in FLUSH TABLES...FOR EXPORT trx_purge_stop(): Release purge_sys->latch before attempting to wake up the purge threads, so that they can actually wake up. This is a regression of commit a13a636c74d9778ec0430ec963dcfd1614f7c81e which attempted to fix MDEV-11802 by ensuring that srv_purge_wakeup() will actually wait until all purge threads wake up. Due to the purge_sys->latch, the threads might never wake up, because some purge threads could end up waiting for purge_sys->latch in trx_undo_prev_version_build() while holding dict_operation_lock in shared mode. This in turn would block any DDL operations, the InnoDB master thread, and InnoDB shutdown. --- storage/innobase/srv/srv0srv.cc | 1 + storage/innobase/trx/trx0purge.cc | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index 81e3b83af05..5f93ff7cd7c 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -2932,6 +2932,7 @@ void srv_purge_wakeup() { ut_ad(!srv_read_only_mode); + ut_ad(!sync_check_iterate(sync_check())); if (srv_force_recovery >= SRV_FORCE_NO_BACKGROUND) { return; diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index 16ee1d2e8e8..603b967484e 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -1781,8 +1781,8 @@ unlock: const int64_t sig_count = os_event_reset(purge_sys->event); purge_sys->state = PURGE_STATE_STOP; - srv_purge_wakeup(); rw_lock_x_unlock(&purge_sys->latch); + srv_purge_wakeup(); /* Wait for purge coordinator to signal that it is suspended. */ os_event_wait_low(purge_sys->event, sig_count); From 279184a04d4028eecbc3c2d928ca270c4912fd10 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Mon, 14 May 2018 19:50:21 +0300 Subject: [PATCH 06/33] MDEV-14562: rocksdb.bloomfilter failed in buildbot Bloom filter is only used when reading the data from disk. If the data happens to be still in the memtable, bloomfilter wont be used. Stabilize the testcase by making sure the data is on disk before we read it. --- storage/rocksdb/mysql-test/rocksdb/r/bloomfilter.result | 5 +++++ storage/rocksdb/mysql-test/rocksdb/r/bloomfilter_skip.result | 5 +++++ .../rocksdb/mysql-test/rocksdb/t/bloomfilter_load_select.inc | 1 + storage/rocksdb/mysql-test/rocksdb/t/disabled.def | 1 - 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/storage/rocksdb/mysql-test/rocksdb/r/bloomfilter.result b/storage/rocksdb/mysql-test/rocksdb/r/bloomfilter.result index 5f1083a1bb2..bc5d685f89b 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/bloomfilter.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/bloomfilter.result @@ -43,6 +43,7 @@ insert t1 select (seq+9) div 10, (seq+4) div 5, (seq+4) div 5, seq, seq, 1000, "aaabbbccc" from seq_1_to_10000; insert t2 select * from t1; +set global rocksdb_force_flush_memtable_now=1; call bloom_start(); select count(*) from t1; count(*) @@ -443,6 +444,7 @@ insert t1 select (seq+9) div 10, (seq+4) div 5, (seq+4) div 5, seq, seq, 1000, "aaabbbccc" from seq_1_to_10000; insert t2 select * from t1; +set global rocksdb_force_flush_memtable_now=1; call bloom_start(); select count(*) from t1; count(*) @@ -843,6 +845,7 @@ insert t1 select (seq+9) div 10, (seq+4) div 5, (seq+4) div 5, seq, seq, 1000, "aaabbbccc" from seq_1_to_10000; insert t2 select * from t1; +set global rocksdb_force_flush_memtable_now=1; call bloom_start(); select count(*) from t1; count(*) @@ -1243,6 +1246,7 @@ insert t1 select (seq+9) div 10, (seq+4) div 5, (seq+4) div 5, seq, seq, 1000, "aaabbbccc" from seq_1_to_10000; insert t2 select * from t1; +set global rocksdb_force_flush_memtable_now=1; call bloom_start(); select count(*) from t1; count(*) @@ -1643,6 +1647,7 @@ insert t1 select (seq+9) div 10, (seq+4) div 5, (seq+4) div 5, seq, seq, 1000, "aaabbbccc" from seq_1_to_10000; insert t2 select * from t1; +set global rocksdb_force_flush_memtable_now=1; call bloom_start(); select count(*) from t1; count(*) diff --git a/storage/rocksdb/mysql-test/rocksdb/r/bloomfilter_skip.result b/storage/rocksdb/mysql-test/rocksdb/r/bloomfilter_skip.result index 2496f349427..28475630564 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/bloomfilter_skip.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/bloomfilter_skip.result @@ -43,6 +43,7 @@ insert t1 select (seq+9) div 10, (seq+4) div 5, (seq+4) div 5, seq, seq, 1000, "aaabbbccc" from seq_1_to_10000; insert t2 select * from t1; +set global rocksdb_force_flush_memtable_now=1; call bloom_start(); select count(*) from t1; count(*) @@ -443,6 +444,7 @@ insert t1 select (seq+9) div 10, (seq+4) div 5, (seq+4) div 5, seq, seq, 1000, "aaabbbccc" from seq_1_to_10000; insert t2 select * from t1; +set global rocksdb_force_flush_memtable_now=1; call bloom_start(); select count(*) from t1; count(*) @@ -843,6 +845,7 @@ insert t1 select (seq+9) div 10, (seq+4) div 5, (seq+4) div 5, seq, seq, 1000, "aaabbbccc" from seq_1_to_10000; insert t2 select * from t1; +set global rocksdb_force_flush_memtable_now=1; call bloom_start(); select count(*) from t1; count(*) @@ -1243,6 +1246,7 @@ insert t1 select (seq+9) div 10, (seq+4) div 5, (seq+4) div 5, seq, seq, 1000, "aaabbbccc" from seq_1_to_10000; insert t2 select * from t1; +set global rocksdb_force_flush_memtable_now=1; call bloom_start(); select count(*) from t1; count(*) @@ -1643,6 +1647,7 @@ insert t1 select (seq+9) div 10, (seq+4) div 5, (seq+4) div 5, seq, seq, 1000, "aaabbbccc" from seq_1_to_10000; insert t2 select * from t1; +set global rocksdb_force_flush_memtable_now=1; call bloom_start(); select count(*) from t1; count(*) diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter_load_select.inc b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter_load_select.inc index 5c122d6bd19..cf8b26847f0 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter_load_select.inc +++ b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter_load_select.inc @@ -5,6 +5,7 @@ insert t1 select (seq+9) div 10, (seq+4) div 5, (seq+4) div 5, seq, seq, 1000, "aaabbbccc" from seq_1_to_10000; insert t2 select * from t1; +set global rocksdb_force_flush_memtable_now=1; # BF conditions (prefix short(4B)|medium(20B)|long(240B)) #0 no eq condition (o, x, x) diff --git a/storage/rocksdb/mysql-test/rocksdb/t/disabled.def b/storage/rocksdb/mysql-test/rocksdb/t/disabled.def index 212e09ce2ff..60f658ec7e1 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/disabled.def +++ b/storage/rocksdb/mysql-test/rocksdb/t/disabled.def @@ -68,7 +68,6 @@ rpl_row_triggers : Requires read-free slave. compact_deletes: MDEV-12663 : rocksdb.compact_deletes times out and causes other tests to fail blind_delete_without_tx_api: MDEV-12286: rocksdb.blind_delete_without_tx_api test fails information_schema: MDEV-14372: unstable testcase -bloomfilter: MDEV-14562 ## ## Tests that fail for some other reason From 4d2a36e8bcaeced7095a5d4b40b87d6ffcfeafb1 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Mon, 14 May 2018 20:25:02 +0300 Subject: [PATCH 07/33] Post-merge fix for rocksdb.add_index_inplace_sstfilewriter MariaDB has a scaled-down version of the test so we need to set @@rocksdb_max_row_locks lower to trigger the desired error (didn't catch this on test BB run because this test is marked as "big") --- .../rocksdb/r/add_index_inplace_sstfilewriter.result | 3 +++ .../mysql-test/rocksdb/t/add_index_inplace_sstfilewriter.test | 3 +++ 2 files changed, 6 insertions(+) diff --git a/storage/rocksdb/mysql-test/rocksdb/r/add_index_inplace_sstfilewriter.result b/storage/rocksdb/mysql-test/rocksdb/r/add_index_inplace_sstfilewriter.result index 18365338d0c..08f2329f688 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/add_index_inplace_sstfilewriter.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/add_index_inplace_sstfilewriter.result @@ -14,11 +14,14 @@ select count(b) from t1; count(b) 300000 ALTER TABLE t1 ADD INDEX kb(b), ALGORITHM=INPLACE; +set @tmp= @@rocksdb_max_row_locks; +set session rocksdb_max_row_locks=1000; ALTER TABLE t1 ADD INDEX kb_copy(b), ALGORITHM=COPY; ERROR HY000: Status error 10 received from RocksDB: Operation aborted: Failed to acquire lock due to max_num_locks limit set session rocksdb_bulk_load=1; ALTER TABLE t1 ADD INDEX kb_copy(b), ALGORITHM=COPY; set session rocksdb_bulk_load=0; +set session rocksdb_max_row_locks=@tmp; SELECT COUNT(*) as c FROM (SELECT COALESCE(LOWER(CONV(BIT_XOR(CAST(CRC32(CONCAT_WS('#', `b`, CONCAT(ISNULL(`b`)))) AS UNSIGNED)), 10, 16)), 0) AS crc FROM `t1` FORCE INDEX(`kb`) UNION DISTINCT diff --git a/storage/rocksdb/mysql-test/rocksdb/t/add_index_inplace_sstfilewriter.test b/storage/rocksdb/mysql-test/rocksdb/t/add_index_inplace_sstfilewriter.test index 3977b38d725..5eac8595f7b 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/add_index_inplace_sstfilewriter.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/add_index_inplace_sstfilewriter.test @@ -66,12 +66,15 @@ ALTER TABLE t1 ADD INDEX kb(b), ALGORITHM=INPLACE; --disable_warnings # now do same index using copy algorithm # hitting max row locks (1M) +set @tmp= @@rocksdb_max_row_locks; +set session rocksdb_max_row_locks=1000; --error ER_RDB_STATUS_GENERAL ALTER TABLE t1 ADD INDEX kb_copy(b), ALGORITHM=COPY; set session rocksdb_bulk_load=1; ALTER TABLE t1 ADD INDEX kb_copy(b), ALGORITHM=COPY; set session rocksdb_bulk_load=0; --enable_warnings +set session rocksdb_max_row_locks=@tmp; # checksum testing SELECT COUNT(*) as c FROM From 2b24b0422002655f1a4b1bbf98b3ae91d2528c93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 14 May 2018 23:22:59 +0300 Subject: [PATCH 08/33] Bug 27122803 - BACKPORT FIX FOR BUG 25899959 TO MYSQL-5.7 Merge a test case and a code change from MySQL 5.7.22. There was no commit message, but a test case was included. https://github.com/mysql/mysql-server/commit/d3ec326bcd8352fcd969dbfd54e5c604db9cd30b There is no Bug 25899959 mentioned in the MySQL 8.0.11 history. Based on the number, it should have been filed before August 2017. Maybe it was initially fixed in a not-yet-public MySQL 9.0 branch? The code change differs from MySQL 5.7, because the mbminmaxlen were split in MariaDB in MDEV-7049. --- mysql-test/suite/gcol/r/innodb_virtual_index.result | 13 +++++++++++++ mysql-test/suite/gcol/t/innodb_virtual_index.test | 8 ++++++++ storage/innobase/handler/handler0alter.cc | 9 +++++++++ 3 files changed, 30 insertions(+) diff --git a/mysql-test/suite/gcol/r/innodb_virtual_index.result b/mysql-test/suite/gcol/r/innodb_virtual_index.result index b1f7976c6c0..a1faac8e1e8 100644 --- a/mysql-test/suite/gcol/r/innodb_virtual_index.result +++ b/mysql-test/suite/gcol/r/innodb_virtual_index.result @@ -198,3 +198,16 @@ VIRTUAL, ADD UNIQUE index idx (col1), algorithm=inplace; ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: INPLACE ADD or DROP of virtual columns cannot be combined with other ALTER TABLE actions. Try ALGORITHM=COPY DROP TABLE t1; SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency; +# +# Bug 27122803 - BACKPORT FIX FOR BUG 25899959 TO MYSQL-5.7 +# +CREATE TABLE t1 (col1 int(10)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +ALTER TABLE t1 ADD col2 char(21) AS (col1 * col1), ADD INDEX n (col2); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `col1` int(10) DEFAULT NULL, + `col2` char(21) GENERATED ALWAYS AS (`col1` * `col1`) VIRTUAL, + KEY `n` (`col2`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 +DROP TABLE t1; diff --git a/mysql-test/suite/gcol/t/innodb_virtual_index.test b/mysql-test/suite/gcol/t/innodb_virtual_index.test index 432faeb65ae..6604a6d94f4 100644 --- a/mysql-test/suite/gcol/t/innodb_virtual_index.test +++ b/mysql-test/suite/gcol/t/innodb_virtual_index.test @@ -224,3 +224,11 @@ VIRTUAL, ADD UNIQUE index idx (col1), algorithm=inplace; DROP TABLE t1; SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency; + +--echo # +--echo # Bug 27122803 - BACKPORT FIX FOR BUG 25899959 TO MYSQL-5.7 +--echo # +CREATE TABLE t1 (col1 int(10)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +ALTER TABLE t1 ADD col2 char(21) AS (col1 * col1), ADD INDEX n (col2); +SHOW CREATE TABLE t1; +DROP TABLE t1; diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 2ae4f65efc5..f27f92dacb5 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -4385,6 +4385,15 @@ prepare_inplace_alter_table_dict( if (ha_alter_info->handler_flags & Alter_inplace_info::ADD_INDEX) { + for (ulint i = 0; i < ctx->num_to_add_vcol; i++) { + /* Set mbminmax for newly added column */ + dict_col_t& col = ctx->add_vcol[i].m_col; + ulint mbminlen, mbmaxlen; + dtype_get_mblen(col.mtype, col.prtype, + &mbminlen, &mbmaxlen); + col.mbminlen = mbminlen; + col.mbmaxlen = mbmaxlen; + } add_v = static_cast( mem_heap_alloc(ctx->heap, sizeof *add_v)); add_v->n_v_col = ctx->num_to_add_vcol; From 0d033b6d34631df9df1f703c92ed0356db1c2365 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Mon, 14 May 2018 23:54:07 +0300 Subject: [PATCH 09/33] Down-scale rocksdb.bulk_load* tests by 2x. This should fix MDEV-13904 --- .../mysql-test/rocksdb/include/bulk_load.inc | 17 +++---- .../mysql-test/rocksdb/r/bulk_load.result | 51 ++++++++----------- .../rocksdb/r/bulk_load_rev_cf.result | 51 ++++++++----------- .../r/bulk_load_rev_cf_and_data.result | 51 ++++++++----------- .../rocksdb/r/bulk_load_rev_data.result | 51 ++++++++----------- 5 files changed, 91 insertions(+), 130 deletions(-) diff --git a/storage/rocksdb/mysql-test/rocksdb/include/bulk_load.inc b/storage/rocksdb/mysql-test/rocksdb/include/bulk_load.inc index 6472b969ce6..8ec97510dbd 100644 --- a/storage/rocksdb/mysql-test/rocksdb/include/bulk_load.inc +++ b/storage/rocksdb/mysql-test/rocksdb/include/bulk_load.inc @@ -50,7 +50,7 @@ eval CREATE TABLE t3( perl; my $fn = $ENV{'ROCKSDB_INFILE'}; open(my $fh, '>', $fn) || die "perl open($fn): $!"; -my $max = 5000000; +my $max = 2500000; my $desc = $ENV{'MTR_DATA_ORDER_DESC'}; my @chars = ("A".."Z", "a".."z", "0".."9"); my @powers_of_26 = (26 * 26 * 26 * 26, 26 * 26 * 26, 26 * 26, 26, 1); @@ -118,15 +118,12 @@ ANALYZE TABLE t1, t2, t3; SHOW TABLE STATUS WHERE name LIKE 't%'; # Make sure all the data is there. -select count(pk) from t1; -select count(a) from t1; -select count(b) from t1; -select count(pk) from t2; -select count(a) from t2; -select count(b) from t2; -select count(pk) from t3; -select count(a) from t3; -select count(b) from t3; +select count(pk),count(a) from t1; +select count(b) from t1; +select count(pk),count(a) from t2; +select count(b) from t2; +select count(pk),count(a) from t3; +select count(b) from t3; # Create a dummy file with a bulk load extesion. It should be removed when # the server starts diff --git a/storage/rocksdb/mysql-test/rocksdb/r/bulk_load.result b/storage/rocksdb/mysql-test/rocksdb/r/bulk_load.result index 4a746d64c87..737d3a3befa 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/bulk_load.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/bulk_load.result @@ -38,9 +38,9 @@ LOAD DATA INFILE INTO TABLE t3; set rocksdb_bulk_load=0; SHOW TABLE STATUS WHERE name LIKE 't%'; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned +t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL +t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL +t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned ANALYZE TABLE t1, t2, t3; Table Op Msg_type Msg_text test.t1 analyze status OK @@ -48,36 +48,27 @@ test.t2 analyze status OK test.t3 analyze status OK SHOW TABLE STATUS WHERE name LIKE 't%'; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned -select count(pk) from t1; -count(pk) -5000000 -select count(a) from t1; -count(a) -5000000 -select count(b) from t1; +t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL +t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL +t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned +select count(pk),count(a) from t1; +count(pk) count(a) +2500000 2500000 +select count(b) from t1; count(b) -5000000 -select count(pk) from t2; -count(pk) -5000000 -select count(a) from t2; -count(a) -5000000 -select count(b) from t2; +2500000 +select count(pk),count(a) from t2; +count(pk) count(a) +2500000 2500000 +select count(b) from t2; count(b) -5000000 -select count(pk) from t3; -count(pk) -5000000 -select count(a) from t3; -count(a) -5000000 -select count(b) from t3; +2500000 +select count(pk),count(a) from t3; +count(pk) count(a) +2500000 2500000 +select count(b) from t3; count(b) -5000000 +2500000 longfilenamethatvalidatesthatthiswillgetdeleted.bulk_load.tmp test.bulk_load.tmp disconnect other; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_rev_cf.result b/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_rev_cf.result index 4fd7ae9d9a5..b4ef029e5c4 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_rev_cf.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_rev_cf.result @@ -38,9 +38,9 @@ LOAD DATA INFILE INTO TABLE t3; set rocksdb_bulk_load=0; SHOW TABLE STATUS WHERE name LIKE 't%'; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned +t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL +t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL +t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned ANALYZE TABLE t1, t2, t3; Table Op Msg_type Msg_text test.t1 analyze status OK @@ -48,36 +48,27 @@ test.t2 analyze status OK test.t3 analyze status OK SHOW TABLE STATUS WHERE name LIKE 't%'; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned -select count(pk) from t1; -count(pk) -5000000 -select count(a) from t1; -count(a) -5000000 -select count(b) from t1; +t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL +t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL +t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned +select count(pk),count(a) from t1; +count(pk) count(a) +2500000 2500000 +select count(b) from t1; count(b) -5000000 -select count(pk) from t2; -count(pk) -5000000 -select count(a) from t2; -count(a) -5000000 -select count(b) from t2; +2500000 +select count(pk),count(a) from t2; +count(pk) count(a) +2500000 2500000 +select count(b) from t2; count(b) -5000000 -select count(pk) from t3; -count(pk) -5000000 -select count(a) from t3; -count(a) -5000000 -select count(b) from t3; +2500000 +select count(pk),count(a) from t3; +count(pk) count(a) +2500000 2500000 +select count(b) from t3; count(b) -5000000 +2500000 longfilenamethatvalidatesthatthiswillgetdeleted.bulk_load.tmp test.bulk_load.tmp disconnect other; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_rev_cf_and_data.result b/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_rev_cf_and_data.result index 7d7c9f34200..b7d5a9c922f 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_rev_cf_and_data.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_rev_cf_and_data.result @@ -38,9 +38,9 @@ LOAD DATA INFILE INTO TABLE t3; set rocksdb_bulk_load=0; SHOW TABLE STATUS WHERE name LIKE 't%'; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned +t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL +t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL +t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned ANALYZE TABLE t1, t2, t3; Table Op Msg_type Msg_text test.t1 analyze status OK @@ -48,36 +48,27 @@ test.t2 analyze status OK test.t3 analyze status OK SHOW TABLE STATUS WHERE name LIKE 't%'; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned -select count(pk) from t1; -count(pk) -5000000 -select count(a) from t1; -count(a) -5000000 -select count(b) from t1; +t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL +t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL +t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned +select count(pk),count(a) from t1; +count(pk) count(a) +2500000 2500000 +select count(b) from t1; count(b) -5000000 -select count(pk) from t2; -count(pk) -5000000 -select count(a) from t2; -count(a) -5000000 -select count(b) from t2; +2500000 +select count(pk),count(a) from t2; +count(pk) count(a) +2500000 2500000 +select count(b) from t2; count(b) -5000000 -select count(pk) from t3; -count(pk) -5000000 -select count(a) from t3; -count(a) -5000000 -select count(b) from t3; +2500000 +select count(pk),count(a) from t3; +count(pk) count(a) +2500000 2500000 +select count(b) from t3; count(b) -5000000 +2500000 longfilenamethatvalidatesthatthiswillgetdeleted.bulk_load.tmp test.bulk_load.tmp disconnect other; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_rev_data.result b/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_rev_data.result index c1b6d48a6a5..7ccc39f3582 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_rev_data.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/bulk_load_rev_data.result @@ -38,9 +38,9 @@ LOAD DATA INFILE INTO TABLE t3; set rocksdb_bulk_load=0; SHOW TABLE STATUS WHERE name LIKE 't%'; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned +t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL +t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL +t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned ANALYZE TABLE t1, t2, t3; Table Op Msg_type Msg_text test.t1 analyze status OK @@ -48,36 +48,27 @@ test.t2 analyze status OK test.t3 analyze status OK SHOW TABLE STATUS WHERE name LIKE 't%'; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t2 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL -t3 ROCKSDB 10 Fixed 5000000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned -select count(pk) from t1; -count(pk) -5000000 -select count(a) from t1; -count(a) -5000000 -select count(b) from t1; +t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL +t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL +t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned +select count(pk),count(a) from t1; +count(pk) count(a) +2500000 2500000 +select count(b) from t1; count(b) -5000000 -select count(pk) from t2; -count(pk) -5000000 -select count(a) from t2; -count(a) -5000000 -select count(b) from t2; +2500000 +select count(pk),count(a) from t2; +count(pk) count(a) +2500000 2500000 +select count(b) from t2; count(b) -5000000 -select count(pk) from t3; -count(pk) -5000000 -select count(a) from t3; -count(a) -5000000 -select count(b) from t3; +2500000 +select count(pk),count(a) from t3; +count(pk) count(a) +2500000 2500000 +select count(b) from t3; count(b) -5000000 +2500000 longfilenamethatvalidatesthatthiswillgetdeleted.bulk_load.tmp test.bulk_load.tmp disconnect other; From 95e9c7054f08409a565bb5e99ea533bd513f478a Mon Sep 17 00:00:00 2001 From: Jacob Mathew Date: Mon, 14 May 2018 16:30:25 -0700 Subject: [PATCH 10/33] MDEV-16101: ADD PARTITION on table partitioned by list does not work with more than 32 list values. This problem occured because the reorganization of the list of values when the number of elements exceeds 32 was not handled correctly. I have fixed the problem by fixing the way that the list values are reorganized when the number of list values exceeds 32. Author: Jacob Mathew. Reviewer: Alexey Botchkov. Merged From: Commit 8e01598 on branch bb-10.3-MDEV-16101 --- mysql-test/r/partition_list.result | 210 +++++++++++++++++++++++++++++ mysql-test/t/partition_list.test | 41 ++++++ sql/partition_info.cc | 4 +- 3 files changed, 254 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/partition_list.result b/mysql-test/r/partition_list.result index 91c1c106cea..f4cd1c9da43 100644 --- a/mysql-test/r/partition_list.result +++ b/mysql-test/r/partition_list.result @@ -334,3 +334,213 @@ f 1 drop table t1; #end of 10.2 tests +# +# Bug MDEV-16101: More than MAX_REF_PARTS values in a list on ALTER TABLE. +# Currently MAX_REF_PARTS = 32. +CREATE TABLE ts1 (a INT, PRIMARY KEY (`a`)) +PARTITION BY LIST (`a`) +(PARTITION `p ts_0` VALUES IN (101,102,103,104,105,106,107,108,109,110, +111,112,113,114,115,116,117,118,119,120, +121,122,123,124,125,126,127,128,129,130, +131,132,133)); +INSERT INTO ts1 +VALUES (101), (102), (103), (104), (105), (106), (107), (108), (109), (110), +(111), (112), (113), (114), (115), (116), (117), (118), (119), (120), +(121), (122), (123), (124), (125), (126), (127), (128), (129), (130), +(131), (132), (133); +INSERT INTO ts1 VALUES (134); +ERROR HY000: Table has no partition for value 134 +SELECT * FROM ts1; +a +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +ALTER TABLE ts1 ADD PARTITION +(PARTITION `p ts_1` VALUES IN (1,2,3,4,5,6,7,8,9,10, +11,12,13,14,15,16,17,18,19,20, +21,22,23,24,25,26,27,28,29,30, +31,32,33)); +INSERT INTO ts1 +VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), +(11), (12), (13), (14), (15), (16), (17), (18), (19), (20), +(21), (22), (23), (24), (25), (26), (27), (28), (29), (30), +(31), (32), (33); +INSERT INTO ts1 VALUES(34); +ERROR HY000: Table has no partition for value 34 +SELECT * FROM ts1; +a +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +ALTER TABLE ts1 REORGANIZE PARTITION `p ts_1` INTO +(PARTITION `p ts_1` VALUES IN (1,2,3,4,5,6,7,8,9,10, +11,12,13,14,15,16,17,18,19,20, +21,22,23,24,25,26,27,28,29,30, +31,32,33,34,35)); +INSERT INTO ts1 VALUES (34), (35); +INSERT INTO ts1 VALUES (36); +ERROR HY000: Table has no partition for value 36 +SELECT * FROM ts1; +a +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +DROP TABLE ts1; diff --git a/mysql-test/t/partition_list.test b/mysql-test/t/partition_list.test index e2b6aff300f..5eadb72a932 100644 --- a/mysql-test/t/partition_list.test +++ b/mysql-test/t/partition_list.test @@ -209,3 +209,44 @@ select * from t1 where f = 1; drop table t1; --echo #end of 10.2 tests + +--echo # +--echo # Bug MDEV-16101: More than MAX_REF_PARTS values in a list on ALTER TABLE. +--echo # Currently MAX_REF_PARTS = 32. +CREATE TABLE ts1 (a INT, PRIMARY KEY (`a`)) +PARTITION BY LIST (`a`) +(PARTITION `p ts_0` VALUES IN (101,102,103,104,105,106,107,108,109,110, + 111,112,113,114,115,116,117,118,119,120, + 121,122,123,124,125,126,127,128,129,130, + 131,132,133)); +INSERT INTO ts1 +VALUES (101), (102), (103), (104), (105), (106), (107), (108), (109), (110), + (111), (112), (113), (114), (115), (116), (117), (118), (119), (120), + (121), (122), (123), (124), (125), (126), (127), (128), (129), (130), + (131), (132), (133); +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +INSERT INTO ts1 VALUES (134); +SELECT * FROM ts1; +ALTER TABLE ts1 ADD PARTITION +(PARTITION `p ts_1` VALUES IN (1,2,3,4,5,6,7,8,9,10, + 11,12,13,14,15,16,17,18,19,20, + 21,22,23,24,25,26,27,28,29,30, + 31,32,33)); +INSERT INTO ts1 +VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), + (11), (12), (13), (14), (15), (16), (17), (18), (19), (20), + (21), (22), (23), (24), (25), (26), (27), (28), (29), (30), + (31), (32), (33); +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +INSERT INTO ts1 VALUES(34); +SELECT * FROM ts1; +ALTER TABLE ts1 REORGANIZE PARTITION `p ts_1` INTO +(PARTITION `p ts_1` VALUES IN (1,2,3,4,5,6,7,8,9,10, + 11,12,13,14,15,16,17,18,19,20, + 21,22,23,24,25,26,27,28,29,30, + 31,32,33,34,35)); +INSERT INTO ts1 VALUES (34), (35); +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +INSERT INTO ts1 VALUES (36); +SELECT * FROM ts1; +DROP TABLE ts1; diff --git a/sql/partition_info.cc b/sql/partition_info.cc index bddc66189e4..f96882552fa 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -1996,9 +1996,11 @@ part_column_list_val *partition_info::add_column_value(THD *thd) into the structure used for 1 column. After this we call ourselves recursively which should always succeed. */ + num_columns= curr_list_object; if (!reorganize_into_single_field_col_val(thd)) { - DBUG_RETURN(add_column_value(thd)); + if (!init_column_part(thd)) + DBUG_RETURN(add_column_value(thd)); } DBUG_RETURN(NULL); } From 681e8ca35e3439a39d2069d8f3ebc61d5e18515b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 15 May 2018 08:18:44 +0300 Subject: [PATCH 11/33] MDEV-16142: Update the InnoDB version number to 5.7.22 --- mysql-test/suite/sys_vars/r/sysvars_innodb.result | 2 +- storage/innobase/include/univ.i | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb.result b/mysql-test/suite/sys_vars/r/sysvars_innodb.result index 7f606f6f572..651461860a2 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb.result +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb.result @@ -3046,7 +3046,7 @@ READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_VERSION SESSION_VALUE NULL -GLOBAL_VALUE 5.7.21 +GLOBAL_VALUE 5.7.22 GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE NULL VARIABLE_SCOPE GLOBAL diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i index 2f423f0b835..e6e87d09a13 100644 --- a/storage/innobase/include/univ.i +++ b/storage/innobase/include/univ.i @@ -41,7 +41,7 @@ Created 1/20/1994 Heikki Tuuri #define INNODB_VERSION_MAJOR 5 #define INNODB_VERSION_MINOR 7 -#define INNODB_VERSION_BUGFIX 21 +#define INNODB_VERSION_BUGFIX 22 /* The following is the InnoDB version as shown in SELECT plugin_version FROM information_schema.plugins; From 21bcfeb9961ca52a06c995cc5d6a76bd7f3fec09 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Tue, 15 May 2018 12:34:10 +0300 Subject: [PATCH 12/33] MDEV-16155: UPDATE on RocksDB table with unique constraint does not work RocksDB now supports "iterator bounds" which are min and max keys that an iterator is interested in. Iterator initialization function doesn't copy the keys, though, it keeps pointers to them. So if the buffer space for the keys is used for another iterator (the one for checking for UNIUQE constraint violation in ha_rocksdb::ha_update_row) then one can get incorrect query result. Fixed by using a separate buffer for iterator bounds in the unique constraint violation check. --- storage/rocksdb/ha_rocksdb.cc | 69 ++++++++++++++----- storage/rocksdb/ha_rocksdb.h | 12 +++- .../rocksdb/t/mariadb_port_fixes.test | 9 +++ 3 files changed, 69 insertions(+), 21 deletions(-) diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc index 8d7809a2213..a637a9b0525 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -9302,8 +9302,16 @@ int ha_rocksdb::check_and_lock_sk(const uint &key_id, The bloom filter may need to be disabled for this lookup. */ + uchar min_bound_buf[MAX_KEY_LENGTH]; + uchar max_bound_buf[MAX_KEY_LENGTH]; + rocksdb::Slice min_bound_slice; + rocksdb::Slice max_bound_slice; const bool total_order_seek = !check_bloom_and_set_bounds( - ha_thd(), kd, new_slice, all_parts_used); + ha_thd(), kd, new_slice, all_parts_used, + min_bound_buf, + max_bound_buf, + &min_bound_slice, + &max_bound_slice); const bool fill_cache = !THDVAR(ha_thd(), skip_fill_cache); const rocksdb::Status s = @@ -9315,7 +9323,7 @@ int ha_rocksdb::check_and_lock_sk(const uint &key_id, rocksdb::Iterator *const iter = row_info.tx->get_iterator( kd.get_cf(), total_order_seek, fill_cache, - m_eq_cond_lower_bound_slice, m_eq_cond_upper_bound_slice, + min_bound_slice, max_bound_slice, true /* read current data */, false /* acquire snapshot */); /* @@ -9723,25 +9731,34 @@ int ha_rocksdb::update_write_row(const uchar *const old_data, If the index was reverse order, upper bound would be 0x0000b3eb003f65c5e78857, and lower bound would be 0x0000b3eb003f65c5e78859. These cover given eq condition range. + + @param lower_bound_buf IN Buffer for lower bound + @param upper_bound_buf IN Buffer for upper bound + + @param outer_u */ void ha_rocksdb::setup_iterator_bounds(const Rdb_key_def &kd, - const rocksdb::Slice &eq_cond) { + const rocksdb::Slice &eq_cond, + uchar *lower_bound_buf, + uchar *upper_bound_buf, + rocksdb::Slice *out_lower_bound, + rocksdb::Slice *out_upper_bound) { uint eq_cond_len = eq_cond.size(); - memcpy(m_eq_cond_upper_bound, eq_cond.data(), eq_cond_len); - kd.successor(m_eq_cond_upper_bound, eq_cond_len); - memcpy(m_eq_cond_lower_bound, eq_cond.data(), eq_cond_len); - kd.predecessor(m_eq_cond_lower_bound, eq_cond_len); + memcpy(upper_bound_buf, eq_cond.data(), eq_cond_len); + kd.successor(upper_bound_buf, eq_cond_len); + memcpy(lower_bound_buf, eq_cond.data(), eq_cond_len); + kd.predecessor(lower_bound_buf, eq_cond_len); if (kd.m_is_reverse_cf) { - m_eq_cond_upper_bound_slice = - rocksdb::Slice((const char *)m_eq_cond_lower_bound, eq_cond_len); - m_eq_cond_lower_bound_slice = - rocksdb::Slice((const char *)m_eq_cond_upper_bound, eq_cond_len); + *out_upper_bound = + rocksdb::Slice((const char *)lower_bound_buf, eq_cond_len); + *out_lower_bound = + rocksdb::Slice((const char *)upper_bound_buf, eq_cond_len); } else { - m_eq_cond_upper_bound_slice = - rocksdb::Slice((const char *)m_eq_cond_upper_bound, eq_cond_len); - m_eq_cond_lower_bound_slice = - rocksdb::Slice((const char *)m_eq_cond_lower_bound, eq_cond_len); + *out_upper_bound = + rocksdb::Slice((const char *)upper_bound_buf, eq_cond_len); + *out_lower_bound = + rocksdb::Slice((const char *)lower_bound_buf, eq_cond_len); } } @@ -9761,7 +9778,11 @@ void ha_rocksdb::setup_scan_iterator(const Rdb_key_def &kd, bool skip_bloom = true; const rocksdb::Slice eq_cond(slice->data(), eq_cond_len); - if (check_bloom_and_set_bounds(ha_thd(), kd, eq_cond, use_all_keys)) { + if (check_bloom_and_set_bounds(ha_thd(), kd, eq_cond, use_all_keys, + m_eq_cond_lower_bound, + m_eq_cond_upper_bound, + &m_eq_cond_lower_bound_slice, + &m_eq_cond_upper_bound_slice)) { skip_bloom = false; } @@ -10943,7 +10964,11 @@ int ha_rocksdb::remove_rows(Rdb_tbl_def *const tbl) { kd.get_infimum_key(reinterpret_cast(key_buf), &key_len); rocksdb::ColumnFamilyHandle *cf = kd.get_cf(); const rocksdb::Slice table_key(key_buf, key_len); - setup_iterator_bounds(kd, table_key); + setup_iterator_bounds(kd, table_key, + m_eq_cond_lower_bound, + m_eq_cond_upper_bound, + &m_eq_cond_lower_bound_slice, + &m_eq_cond_upper_bound_slice); opts.iterate_lower_bound = &m_eq_cond_lower_bound_slice; opts.iterate_upper_bound = &m_eq_cond_upper_bound_slice; std::unique_ptr it(rdb->NewIterator(opts, cf)); @@ -12723,10 +12748,16 @@ void Rdb_background_thread::run() { bool ha_rocksdb::check_bloom_and_set_bounds(THD *thd, const Rdb_key_def &kd, const rocksdb::Slice &eq_cond, - const bool use_all_keys) { + const bool use_all_keys, + uchar *lower_bound_buf, + uchar *upper_bound_buf, + rocksdb::Slice *out_lower_bound, + rocksdb::Slice *out_upper_bound) { bool can_use_bloom = can_use_bloom_filter(thd, kd, eq_cond, use_all_keys); if (!can_use_bloom) { - setup_iterator_bounds(kd, eq_cond); + setup_iterator_bounds(kd, eq_cond, + lower_bound_buf, upper_bound_buf, + out_lower_bound, out_upper_bound); } return can_use_bloom; } diff --git a/storage/rocksdb/ha_rocksdb.h b/storage/rocksdb/ha_rocksdb.h index 6083dd73020..5f3d97918fe 100644 --- a/storage/rocksdb/ha_rocksdb.h +++ b/storage/rocksdb/ha_rocksdb.h @@ -653,13 +653,21 @@ class ha_rocksdb : public my_core::handler { enum ha_rkey_function find_flag) const MY_ATTRIBUTE((__nonnull__, __warn_unused_result__)); void setup_iterator_bounds(const Rdb_key_def &kd, - const rocksdb::Slice &eq_cond); + const rocksdb::Slice &eq_cond, + uchar *lower_bound_buf, + uchar *upper_bound_buf, + rocksdb::Slice *out_lower_bound, + rocksdb::Slice *out_upper_bound); bool can_use_bloom_filter(THD *thd, const Rdb_key_def &kd, const rocksdb::Slice &eq_cond, const bool use_all_keys); bool check_bloom_and_set_bounds(THD *thd, const Rdb_key_def &kd, const rocksdb::Slice &eq_cond, - const bool use_all_keys); + const bool use_all_keys, + uchar *lower_bound_buf, + uchar *upper_bound_buf, + rocksdb::Slice *out_lower_bound, + rocksdb::Slice *out_upper_bound); void setup_scan_iterator(const Rdb_key_def &kd, rocksdb::Slice *slice, const bool use_all_keys, const uint eq_cond_len) MY_ATTRIBUTE((__nonnull__)); diff --git a/storage/rocksdb/mysql-test/rocksdb/t/mariadb_port_fixes.test b/storage/rocksdb/mysql-test/rocksdb/t/mariadb_port_fixes.test index a48c8a5e426..7282ec237c2 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/mariadb_port_fixes.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/mariadb_port_fixes.test @@ -92,3 +92,12 @@ ALTER TABLE t1 AUTO_INCREMENT 10; DROP TABLE t1; +--echo # +--echo # MDEV-16155: UPDATE on RocksDB table with unique constraint does not work +--echo # +CREATE TABLE t1 (a INT, b CHAR(8), UNIQUE INDEX(a)) ENGINE=RocksDB; +INSERT INTO t1 (a,b) VALUES (1,'foo'),(2,'bar'); +UPDATE t1 SET a=a+100; +SELECT * FROM t1; +DROP TABLE t1; + From 9d6ec6d14a25293201670a97664ea3f60584d3cb Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 12 May 2018 12:50:34 +0200 Subject: [PATCH 13/33] update C/C --- libmariadb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmariadb b/libmariadb index 668757aaa9a..27b2f3d1f15 160000 --- a/libmariadb +++ b/libmariadb @@ -1 +1 @@ -Subproject commit 668757aaa9a55d2bcd806908cb5a8e806cd6dc31 +Subproject commit 27b2f3d1f1550dfaee0f63a331a406ab31c1b37e From 93efa48a7b972fc463406603574a4d508eefe792 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 13 May 2018 18:50:21 +0200 Subject: [PATCH 14/33] fix failing main.mysql_client_test test on 32bit in `ulonglong=ulong*uint` multiplication is done in ulong, wrapping around on 32bit. This became visible after C/C changed the default charset to utf8, thus changing mbmaxlem from 1 to 3. --- tests/mysql_client_fw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/mysql_client_fw.c b/tests/mysql_client_fw.c index f69eb28a287..4d036887629 100644 --- a/tests/mysql_client_fw.c +++ b/tests/mysql_client_fw.c @@ -768,7 +768,7 @@ static void do_verify_prepare_field(MYSQL_RES *result, { MYSQL_FIELD *field; CHARSET_INFO *cs; - ulonglong expected_field_length; + ulonglong expected_field_length= length; if (!(field= mysql_fetch_field_direct(result, no))) { @@ -777,7 +777,7 @@ static void do_verify_prepare_field(MYSQL_RES *result, } cs= get_charset(field->charsetnr, 0); DIE_UNLESS(cs); - if ((expected_field_length= length * cs->mbmaxlen) > UINT_MAX32) + if ((expected_field_length*= cs->mbmaxlen) > UINT_MAX32) expected_field_length= UINT_MAX32; if (!opt_silent) { From 445ac662c369756c7465d687e40225ffcce28e74 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 14 May 2018 16:44:03 +0200 Subject: [PATCH 15/33] MDEV-15755 Query crashing MariaDB in cleanup_after_query set the pointer to NULL to avoid double-free when the item is cleaned up many times (once in JOIN_TAB::cleanup(): tmp->jtbm_subselect->cleanup() and once at the end of the query, with all other items) --- mysql-test/r/subselect-crash_15755.result | 317 ++++++++++++++++++++++ mysql-test/t/subselect-crash_15755.test | 60 ++++ sql/item_subselect.cc | 1 + 3 files changed, 378 insertions(+) create mode 100644 mysql-test/r/subselect-crash_15755.result create mode 100644 mysql-test/t/subselect-crash_15755.test diff --git a/mysql-test/r/subselect-crash_15755.result b/mysql-test/r/subselect-crash_15755.result new file mode 100644 index 00000000000..81b4bd16ab5 --- /dev/null +++ b/mysql-test/r/subselect-crash_15755.result @@ -0,0 +1,317 @@ +set global innodb_stats_persistent= 1; +drop table if exists t1; +Warnings: +Note 1051 Unknown table 'test.t1' +create table t1 ( +f1 bigint(20) default 0, +f2 varchar(50) default '', +f3 int(10) default 0, +f4 bigint(20) default 0, +f5 bigint(20) default 0, +f6 varchar(50) default '', +f7 varchar(64) default '', +f8 varchar(30) default '', +f9 varchar(30) default '', +f10 bigint(20) default 0, +f11 bigint(20) default 0, +f12 bigint(20) default 0, +f13 bigint(20) default 0, +f14 varchar(50) default '', +f15 varchar(100) default '', +f16 varchar(30) default '', +f17 varchar(40) default '', +f18 varchar(30) default '', +f19 varchar(10) default '', +f20 varchar(30) default '', +f21 int(10) default 0, +f22 int(10) default 0, +f23 int(10) default 0, +f24 int(10) default 0, +f25 varchar(20) default '', +f26 varchar(20) default '', +f27 varchar(100) default '', +f28 varchar(55) default '', +f29 varchar(20) default '', +f30 varchar(100) default '', +f31 varchar(30) default '', +f32 varchar(20) default '', +f33 int(10) default 0, +f34 int(10) default 0, +f35 varchar(30) default '', +f36 varchar(30) default '', +f37 varchar(30) default '', +f38 varchar(20) default '', +f39 tinyint(4) default 0, +f40 tinyint(4) default 0, +f41 bigint(20) default 0, +f42 varchar(50) default '', +f43 varchar(50) default '', +f44 varchar(50) default '', +f45 int(10) default 0, +f46 tinyint(1) default 0 +) engine=innodb row_format=dynamic; +insert into t1 () values (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(); +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +select * from t1 where f2 in (select f2 from t1 group by f2 having count(distinct f3) = 1); +f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19 f20 f21 f22 f23 f24 f25 f26 f27 f28 f29 f30 f31 f32 f33 f34 f35 f36 f37 f38 f39 f40 f41 f42 f43 f44 f45 f46 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +drop table t1; +set global innodb_stats_persistent= 0; diff --git a/mysql-test/t/subselect-crash_15755.test b/mysql-test/t/subselect-crash_15755.test new file mode 100644 index 00000000000..79e259d6337 --- /dev/null +++ b/mysql-test/t/subselect-crash_15755.test @@ -0,0 +1,60 @@ +--source include/have_innodb.inc +set global innodb_stats_persistent= 1; +drop table if exists t1; +create table t1 ( + f1 bigint(20) default 0, + f2 varchar(50) default '', + f3 int(10) default 0, + f4 bigint(20) default 0, + f5 bigint(20) default 0, + f6 varchar(50) default '', + f7 varchar(64) default '', + f8 varchar(30) default '', + f9 varchar(30) default '', + f10 bigint(20) default 0, + f11 bigint(20) default 0, + f12 bigint(20) default 0, + f13 bigint(20) default 0, + f14 varchar(50) default '', + f15 varchar(100) default '', + f16 varchar(30) default '', + f17 varchar(40) default '', + f18 varchar(30) default '', + f19 varchar(10) default '', + f20 varchar(30) default '', + f21 int(10) default 0, + f22 int(10) default 0, + f23 int(10) default 0, + f24 int(10) default 0, + f25 varchar(20) default '', + f26 varchar(20) default '', + f27 varchar(100) default '', + f28 varchar(55) default '', + f29 varchar(20) default '', + f30 varchar(100) default '', + f31 varchar(30) default '', + f32 varchar(20) default '', + f33 int(10) default 0, + f34 int(10) default 0, + f35 varchar(30) default '', + f36 varchar(30) default '', + f37 varchar(30) default '', + f38 varchar(20) default '', + f39 tinyint(4) default 0, + f40 tinyint(4) default 0, + f41 bigint(20) default 0, + f42 varchar(50) default '', + f43 varchar(50) default '', + f44 varchar(50) default '', + f45 int(10) default 0, + f46 tinyint(1) default 0 +) engine=innodb row_format=dynamic; + +insert into t1 () values (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(); +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +select * from t1 where f2 in (select f2 from t1 group by f2 having count(distinct f3) = 1); +drop table t1; +set global innodb_stats_persistent= 0; diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 4214980c36c..a8e83d298f6 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -156,6 +156,7 @@ void Item_subselect::cleanup() reset(); filesort_buffer.free_sort_buffer(); my_free(sortbuffer.str); + sortbuffer= null_lex_str; value_assigned= 0; expr_cache= 0; From c14c958c6cd00296cccc10ce523248130be65ec5 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 14 May 2018 21:05:51 +0200 Subject: [PATCH 16/33] cleanup: vcol_in_partition_func_processor rename to post_fix_fields_part_expr_processor() because it's only used after fix_fields in fix_fields_part_func() and can be used for various post-fix_fields fixups --- sql/item.cc | 9 +-------- sql/item.h | 4 ++-- sql/sql_partition.cc | 2 +- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/sql/item.cc b/sql/item.cc index 876472c0bd9..fbc4ec22c6e 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -5761,18 +5761,11 @@ error: return TRUE; } -/* - @brief - Mark virtual columns as used in a partitioning expression -*/ - -bool Item_field::vcol_in_partition_func_processor(void *int_arg) +bool Item_field::post_fix_fields_part_expr_processor(void *int_arg) { DBUG_ASSERT(fixed); if (field->vcol_info) - { field->vcol_info->mark_as_in_partitioning_expr(); - } return FALSE; } diff --git a/sql/item.h b/sql/item.h index 6f6b8bf08ec..423ee4cc089 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1676,7 +1676,7 @@ public: fields. */ virtual bool check_partition_func_processor(void *arg) { return 1;} - virtual bool vcol_in_partition_func_processor(void *arg) { return 0; } + virtual bool post_fix_fields_part_expr_processor(void *arg) { return 0; } virtual bool rename_fields_processor(void *arg) { return 0; } /** Processor used to check acceptability of an item in the defining expression for a virtual column @@ -2649,7 +2649,7 @@ public: bool register_field_in_write_map(void *arg); bool register_field_in_bitmap(void *arg); bool check_partition_func_processor(void *int_arg) {return FALSE;} - bool vcol_in_partition_func_processor(void *bool_arg); + bool post_fix_fields_part_expr_processor(void *bool_arg); bool check_valid_arguments_processor(void *bool_arg); bool check_field_expression_processor(void *arg); bool enumerate_field_refs_processor(void *arg); diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 4c91f781c2e..f5467e85f62 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -949,7 +949,7 @@ static bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table, thd->lex->allow_sum_func= 0; if (!(error= func_expr->fix_fields(thd, (Item**)&func_expr))) - func_expr->walk(&Item::vcol_in_partition_func_processor, 0, NULL); + func_expr->walk(&Item::post_fix_fields_part_expr_processor, 0, NULL); /* Restore agg_field/agg_func and allow_sum_func, From c29312421e9dd6b8b6be332788cbab0621cbcb9f Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 14 May 2018 21:21:59 +0200 Subject: [PATCH 17/33] MDEV-14750 Valgrind Invalid read, ASAN heap-use-after-free in Item_ident::print upon SHOW CREATE on partitioned table items in the partitioning function were taking the table name from the table's field (in set_field(from_field) in Item_field::fix_fields) and field's table_name is TABLE::alias. But alias is changed for every statement, and can be realloced if next statement uses a longer alias. But partitioning items are fixed once and live as long as the TABLE does. So if an alias is realloced, pointers to the old alias string will become invalid. Fix partitioning item table_name to point to the actual table name instead. --- .../parts/r/{quoting.result => show_create.result} | 12 ++++++++++++ .../suite/parts/t/{quoting.test => show_create.test} | 9 +++++++++ sql/item.cc | 4 ++++ 3 files changed, 25 insertions(+) rename mysql-test/suite/parts/r/{quoting.result => show_create.result} (89%) rename mysql-test/suite/parts/t/{quoting.test => show_create.test} (73%) diff --git a/mysql-test/suite/parts/r/quoting.result b/mysql-test/suite/parts/r/show_create.result similarity index 89% rename from mysql-test/suite/parts/r/quoting.result rename to mysql-test/suite/parts/r/show_create.result index 66606832e77..79ac61d180d 100644 --- a/mysql-test/suite/parts/r/quoting.result +++ b/mysql-test/suite/parts/r/show_create.result @@ -91,3 +91,15 @@ t2 CREATE TABLE "t2" ( PARTITION BY RANGE ("f1") (PARTITION "p1" VALUES LESS THAN MAXVALUE ENGINE = MyISAM) drop table t1, t2; +set sql_mode=default; +create table t_partition (f1 int) partition by hash(f1) partitions 2; +select * from t_partition as tbl; +f1 +show create table t_partition; +Table Create Table +t_partition CREATE TABLE `t_partition` ( + `f1` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 + PARTITION BY HASH (`f1`) +PARTITIONS 2 +drop table t_partition; diff --git a/mysql-test/suite/parts/t/quoting.test b/mysql-test/suite/parts/t/show_create.test similarity index 73% rename from mysql-test/suite/parts/t/quoting.test rename to mysql-test/suite/parts/t/show_create.test index 61af8d2d345..9c43b163790 100644 --- a/mysql-test/suite/parts/t/quoting.test +++ b/mysql-test/suite/parts/t/show_create.test @@ -30,3 +30,12 @@ set sql_mode=ansi_quotes; show create table t1; show create table t2; drop table t1, t2; +set sql_mode=default; + +# +# MDEV-14750 Valgrind Invalid read, ASAN heap-use-after-free in Item_ident::print upon SHOW CREATE on partitioned table +# +create table t_partition (f1 int) partition by hash(f1) partitions 2; +select * from t_partition as tbl; +show create table t_partition; +drop table t_partition; diff --git a/sql/item.cc b/sql/item.cc index fbc4ec22c6e..68761293682 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -5766,6 +5766,10 @@ bool Item_field::post_fix_fields_part_expr_processor(void *int_arg) DBUG_ASSERT(fixed); if (field->vcol_info) field->vcol_info->mark_as_in_partitioning_expr(); + /* + Update table_name to be real table name, not the alias. Because alias is + reallocated for every statement, and this item has a long life time */ + table_name= field->table->s->table_name.str; return FALSE; } From 77cd754229ba74eb87518285f48e1d95d00fbde9 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 14 May 2018 23:24:26 +0200 Subject: [PATCH 18/33] MDEV-16110 ALTER with ALGORITHM=INPLACE breaks temporary table with virtual columns Part one, non-temporary tables. Rrenaming a column can make destructive changes to the TABLE. This TABLE cannot be used anymore and needs to be reopened even if ALTER TABLE was aborted with an error. --- mysql-test/r/alter_table_errors.result | 10 ++++++++++ mysql-test/t/alter_table_errors.test | 10 ++++++++++ sql/sql_table.cc | 1 + 3 files changed, 21 insertions(+) create mode 100644 mysql-test/r/alter_table_errors.result create mode 100644 mysql-test/t/alter_table_errors.test diff --git a/mysql-test/r/alter_table_errors.result b/mysql-test/r/alter_table_errors.result new file mode 100644 index 00000000000..020a30304d0 --- /dev/null +++ b/mysql-test/r/alter_table_errors.result @@ -0,0 +1,10 @@ +create table t (a int, v int as (a)) engine=innodb; +alter table t change column a b tinyint, algorithm=inplace; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY +show create table t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL, + `v` int(11) GENERATED ALWAYS AS (`a`) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +drop table t; diff --git a/mysql-test/t/alter_table_errors.test b/mysql-test/t/alter_table_errors.test new file mode 100644 index 00000000000..d9982ac26f4 --- /dev/null +++ b/mysql-test/t/alter_table_errors.test @@ -0,0 +1,10 @@ +--source include/have_innodb.inc + +# +# MDEV-16110 ALTER with ALGORITHM=INPLACE breaks temporary table with virtual columns +# +create table t (a int, v int as (a)) engine=innodb; +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +alter table t change column a b tinyint, algorithm=inplace; +show create table t; +drop table t; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 1ed2194b09a..b6d46ff82ab 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -7677,6 +7677,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, if (field->default_value) field->default_value->expr->walk(&Item::rename_fields_processor, 1, &column_rename_param); + table->m_needs_reopen= 1; // because new column name is on thd->mem_root } /* Check if field is changed */ From 182db5a1b79e0be27e8191f9bea7c8cd3dbe22a3 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 15 May 2018 10:18:39 +0200 Subject: [PATCH 19/33] disable galera.pxc-421 test --- mysql-test/suite/galera/disabled.def | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index 153772e5831..14aa22727c2 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -31,3 +31,4 @@ galera.MW-44 : MDEV-15809 Test failure on galera.MW-44 galera.galera_pc_ignore_sb : MDEV-15811 Test failure on galera_pc_ignore_sb galera_kill_applier : race condition at the start of the test galera_ist_progress: MDEV-15236 galera_ist_progress fails when trying to read transfer status +pxc-421: Lock timeout exceeded From 0e296947db503eed2db5b995676f4d9a454c9001 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 15 May 2018 15:12:54 +0200 Subject: [PATCH 20/33] add missing test result followup for 21bcfeb9961 --- .../mysql-test/rocksdb/r/mariadb_port_fixes.result | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/storage/rocksdb/mysql-test/rocksdb/r/mariadb_port_fixes.result b/storage/rocksdb/mysql-test/rocksdb/r/mariadb_port_fixes.result index eeb261d22e7..e9fe026120a 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/mariadb_port_fixes.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/mariadb_port_fixes.result @@ -96,3 +96,14 @@ CREATE TABLE t1 (a INT) ENGINE=RocksDB; INSERT INTO t1 VALUES (1); ALTER TABLE t1 AUTO_INCREMENT 10; DROP TABLE t1; +# +# MDEV-16155: UPDATE on RocksDB table with unique constraint does not work +# +CREATE TABLE t1 (a INT, b CHAR(8), UNIQUE INDEX(a)) ENGINE=RocksDB; +INSERT INTO t1 (a,b) VALUES (1,'foo'),(2,'bar'); +UPDATE t1 SET a=a+100; +SELECT * FROM t1; +a b +101 foo +102 bar +DROP TABLE t1; From 4ab180ad5e9c67427b561035e4b8e193d429fe5a Mon Sep 17 00:00:00 2001 From: Monty Date: Tue, 15 May 2018 17:02:08 +0300 Subject: [PATCH 21/33] MDEV-15461 Check Constraints with binary logging makes insert inconsistent Problem was that verify_constraints() didn't check if there was an error as part of evaluating constraints (can happen in strict mode). In one-row-insert the error was ignored when using binary logging as binary logging clear errors if insert succeeded. In multi-row-insert the error was noticed for the second row. After this fix one will get an error for both one and multi-row inserts if the constraints generates a warning in strict mode. --- mysql-test/r/check_constraint.result | 41 ++++++++++++++++++++++++++++ mysql-test/t/check_constraint.test | 24 ++++++++++++++++ sql/table.cc | 21 ++++++++++++-- 3 files changed, 83 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/check_constraint.result b/mysql-test/r/check_constraint.result index 70d64cd6ff7..9a32e6f12bc 100644 --- a/mysql-test/r/check_constraint.result +++ b/mysql-test/r/check_constraint.result @@ -156,3 +156,44 @@ create table t1 (id int auto_increment primary key, datecol datetime, check (dat insert into t1 (datecol) values (now()); insert into t1 (datecol) values (now()); drop table t1; +CREATE TABLE t1 ( +EmployeeID SMALLINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, +FirstName VARCHAR(30) NOT NULL CHECK (CHAR_LENGTH(FirstName > 2)) +); +INSERT INTO t1 VALUES (NULL, 'Ken'); +ERROR 22007: Truncated incorrect DOUBLE value: 'Ken' +SHOW WARNINGS; +Level Code Message +Error 1292 Truncated incorrect DOUBLE value: 'Ken' +Error 4025 CONSTRAINT `FirstName` failed for `test`.`t1` +INSERT INTO t1 VALUES (NULL, 'Ken'),(NULL, 'Brian'); +ERROR 22007: Truncated incorrect DOUBLE value: 'Ken' +SHOW WARNINGS; +Level Code Message +Error 1292 Truncated incorrect DOUBLE value: 'Ken' +Error 4025 CONSTRAINT `FirstName` failed for `test`.`t1` +INSERT IGNORE INTO t1 VALUES (NULL, 'Ken'); +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'Ken' +INSERT IGNORE INTO t1 VALUES (NULL, 'Ken'),(NULL, 'Brian'); +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'Ken' +Warning 1292 Truncated incorrect DOUBLE value: 'Brian' +set sql_mode=""; +INSERT INTO t1 VALUES (NULL, 'Ken'); +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'Ken' +INSERT INTO t1 VALUES (NULL, 'Ken'),(NULL, 'Brian'); +Warnings: +Warning 1292 Truncated incorrect DOUBLE value: 'Ken' +Warning 1292 Truncated incorrect DOUBLE value: 'Brian' +set sql_mode=default; +select * from t1; +EmployeeID FirstName +1 Ken +2 Ken +3 Brian +4 Ken +5 Ken +6 Brian +drop table t1; diff --git a/mysql-test/t/check_constraint.test b/mysql-test/t/check_constraint.test index 9a77736acd7..02081071bd4 100644 --- a/mysql-test/t/check_constraint.test +++ b/mysql-test/t/check_constraint.test @@ -111,3 +111,27 @@ create table t1 (id int auto_increment primary key, datecol datetime, check (dat insert into t1 (datecol) values (now()); insert into t1 (datecol) values (now()); drop table t1; + +# +# MDEV-15461 Check Constraints with binary logging makes insert inconsistent +# + +CREATE TABLE t1 ( + EmployeeID SMALLINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, + FirstName VARCHAR(30) NOT NULL CHECK (CHAR_LENGTH(FirstName > 2)) +); + +--error ER_TRUNCATED_WRONG_VALUE +INSERT INTO t1 VALUES (NULL, 'Ken'); +SHOW WARNINGS; +--error ER_TRUNCATED_WRONG_VALUE +INSERT INTO t1 VALUES (NULL, 'Ken'),(NULL, 'Brian'); +SHOW WARNINGS; +INSERT IGNORE INTO t1 VALUES (NULL, 'Ken'); +INSERT IGNORE INTO t1 VALUES (NULL, 'Ken'),(NULL, 'Brian'); +set sql_mode=""; +INSERT INTO t1 VALUES (NULL, 'Ken'); +INSERT INTO t1 VALUES (NULL, 'Ken'),(NULL, 'Brian'); +set sql_mode=default; +select * from t1; +drop table t1; diff --git a/sql/table.cc b/sql/table.cc index fff2be4f154..d7cbf555b72 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -5116,14 +5116,25 @@ int TABLE_LIST::view_check_option(THD *thd, bool ignore_failure) int TABLE::verify_constraints(bool ignore_failure) { + /* + We have to check is_error() first as we are checking it for each + constraint to catch fatal warnings. + */ + if (in_use->is_error()) + return (VIEW_CHECK_ERROR); + /* go trough check option clauses for fields and table */ if (check_constraints && !(in_use->variables.option_bits & OPTION_NO_CHECK_CONSTRAINT_CHECKS)) { for (Virtual_column_info **chk= check_constraints ; *chk ; chk++) { - /* yes! NULL is ok, see 4.23.3.4 Table check constraints, part 2, SQL:2016 */ - if ((*chk)->expr->val_int() == 0 && !(*chk)->expr->null_value) + /* + yes! NULL is ok. + see 4.23.3.4 Table check constraints, part 2, SQL:2016 + */ + if (((*chk)->expr->val_int() == 0 && !(*chk)->expr->null_value) || + in_use->is_error()) { my_error(ER_CONSTRAINT_FAILED, MYF(ignore_failure ? ME_JUST_WARNING : 0), (*chk)->name.str, @@ -5132,7 +5143,11 @@ int TABLE::verify_constraints(bool ignore_failure) } } } - return(VIEW_CHECK_OK); + /* + We have to check in_use() as checking constraints may have generated + warnings that should be treated as errors + */ + return(!in_use->is_error() ? VIEW_CHECK_OK : VIEW_CHECK_ERROR); } From d9f9cd1a102f17a1a23086585588d119ffff2578 Mon Sep 17 00:00:00 2001 From: Elena Stepanova Date: Tue, 15 May 2018 23:42:20 +0300 Subject: [PATCH 22/33] Updated list of unstable tests for 10.2.15 --- mysql-test/unstable-tests | 236 +++++++++++++++++++------------------- 1 file changed, 119 insertions(+), 117 deletions(-) diff --git a/mysql-test/unstable-tests b/mysql-test/unstable-tests index 0bae37d2540..23d1924fff8 100644 --- a/mysql-test/unstable-tests +++ b/mysql-test/unstable-tests @@ -23,67 +23,64 @@ # ############################################################################## -# Based on 10.2 dcb59373d54d2889204b859a2e50dc286b1441a2 +# Based on 10.2 4ab180ad5e9c67427b561035e4b8e193d429fe5a -main.alter_table : Modified in 10.2.13 +main.alter_table_errors : Added in 10.2.15 main.analyze_stmt_slow_query_log : MDEV-12237 - Wrong result +main.assign_key_cache : Added in 10.2.15 +main.assign_key_cache_debug : Added in 10.2.15 main.auth_named_pipe : MDEV-14724 - System error 2 main.case : Modified in 10.2.14 -main.check_constraint : Modified in 10.2.14 +main.check_constraint : Modified in 10.2.15 +main.connect : Modified in 10.2.15 +main.connect_debug : Added in 10.2.15 main.connect2 : MDEV-13885 - Server crash -main.create : Modified in 10.2.13 main.cte_nonrecursive : Modified in 10.2.14 -main.cte_recursive : Modified in 10.2.13 +main.cte_recursive : Modified in 10.2.15 main.ctype_latin1 : Modified in 10.2.14 +main.ctype_ucs : Modified in 10.2.15 main.ctype_utf8 : Modified in 10.2.14 -main.derived : Modified in 10.2.13 -main.derived_cond_pushdown : Modified in 10.2.13 +main.ctype_utf8mb4 : Modified in 10.2.15 +main.derived_cond_pushdown : Modified in 10.2.15 main.distinct : MDEV-14194 - Crash main.drop_bad_db_type : MDEV-15676 - Wrong result -main.dyncol : Modified in 10.2.13 main.events_2 : MDEV-13277 - Crash main.events_slowlog : MDEV-12821 - Wrong result main.fast_prefix_index_fetch_innodb : Modified in 10.2.14 -main.fulltext : Modified in 10.2.13 -main.func_concat : Modified in 10.2.13 main.func_date_add : Modified in 10.2.14 -main.func_isnull : Modified in 10.2.13 main.func_json : Modified in 10.2.14 -main.func_str : Modified in 10.2.13 +main.func_str : Modified in 10.2.15 main.func_time : Modified in 10.2.14 -main.gis-rtree : Modified in 10.2.13 main.having : Modified in 10.2.14 main.index_merge_innodb : MDEV-7142 - Plan mismatch main.innodb_mysql_lock : MDEV-7861 - Wrong result -main.join_cache : Modified in 10.2.13 main.join_outer : Modified in 10.2.14 main.kill-2 : MDEV-13257 - Wrong result main.kill_processlist-6619 : MDEV-10793 - Wrong result +main.lock : Modified in 10.2.15 main.log_slow : MDEV-13263 - Wrong result -main.mdev_14586 : Modified in 10.2.13 -main.mdev-504 : MDEV-15171 - warning -main.merge : Modified in 10.2.13 -main.myisam_optimize : Modified in 10.2.13 +main.mdev375 : Modified in 10.2.15 +main.mdev-504 : MDEV-15171 - warning +main.myisam : Modified in 10.2.15 +main.myisam_recover : Modified in 10.2.15 main.mysql_client_test_nonblock : CONC-208 - Error on Power; MDEV-15096 - exec failed main.mysql_upgrade_noengine : MDEV-14355 - Wrong result main.mysql_upgrade_ssl : MDEV-13492 - Unknown SSL error main.mysqldump : MDEV-14800 - Stack smashing detected -main.mysqldump-nl : Modified in 10.2.13 main.mysqld_option_err : MDEV-12747 - Timeout main.mysqlhotcopy_myisam : MDEV-10995 - Hang on debug main.mysqltest : MDEV-13887 - Wrong result main.openssl_1 : MDEV-13492 - Unknown SSL error -main.order_by : Modified in 10.2.13 main.order_by_optimizer_innodb : MDEV-10683 - Wrong result -main.partition : Modified in 10.2.13 +main.parser : Modified in 10.2.15 main.partition_debug_sync : MDEV-15669 - Deadlock found when trying to get lock -main.partition_innodb : Modified in 10.2.13 -main.ps : MDEV-11017 - Wrong result; modified in 10.2.13 +main.partition_list : Modified in 10.2.15 +main.ps : MDEV-11017 - Wrong result; modified in 10.2.15 main.ps_qc_innodb : Added in 10.2.14 -main.query_cache : Modified in 10.2.14 -main.query_cache_debug : MDEV-15281 - Query cache is disabled; modified in 10.2.13 +main.query_cache : MDEV-16180 - Wrong result; modified in 10.2.14 +main.query_cache_debug : MDEV-15281 - Query cache is disabled main.range_vs_index_merge_innodb : MDEV-15283 - Server has gone away -main.repair : Modified in 10.2.13 +main.read_only_innodb : Modified in 10.2.15 main.select : MDEV-15430 - Wrong result with clang-4 main.select_jcl6 : MDEV-15430 - Wrong result with clang-4 main.select_pkeycache : MDEV-15430 - Wrong result with clang-4 @@ -91,37 +88,37 @@ main.set_statement : MDEV-13183 - Wrong result main.shutdown : Modified in 10.2.14 main.shm : MDEV-12727 - Mismatch, ERROR 2013 main.show_explain : MDEV-10674 - Wrong result code -main.sp : MDEV-7866 - Mismatch; modified in 10.2.14 +main.sp : MDEV-7866 - Mismatch; modified in 10.2.15 +main.sp-destruct : Modified in 10.2.15 +main.sp-innodb : Modified in 10.2.15 main.ssl_ca : MDEV-10895 - SSL connection error on Power main.ssl_cert_verify : MDEV-13735 - Server crash main.ssl_connect : MDEV-13492 - Unknown SSL error main.ssl_timeout : MDEV-11244 - Crash main.stat_tables_par : MDEV-13266 - Wrong result +main.statistics : Modified in 10.2.15 main.status : MDEV-13255 - Wrong result -main.subselect : Modified in 10.2.13 -main.subselect4 : Modified in 10.2.14 +main.subselect4 : Modified in 10.2.15 +main.subselect-crash_15755 : Added in 10.2.15 main.subselect_innodb : MDEV-10614 - Wrong result main.subselect_mat : Modified in 10.2.14 +main.subselect_sj : Modified in 10.2.15 main.symlink-myisam-11902 : MDEV-15098 - Error 40 from storage engine main.tc_heuristic_recover : MDEV-14189 - Wrong result -main.thread_id_overflow : Added in 10.2.13 main.type_blob : MDEV-15195 - Wrong result main.type_datetime_hires : MDEV-15430 - Wrong result with clang-4 main.type_decimal : Modified in 10.2.14 main.type_float : MDEV-15430 - Wrong result with clang-4 main.type_temporal_innodb : Modified in 10.2.14 main.type_time : Modified in 10.2.14 -main.type_time_6065 : Modified in 10.2.13 main.type_time_hires : MDEV-15430 - Wrong result with clang-4 main.type_timestamp_hires : MDEV-15430 - Wrong result with clang-4 -main.union : Modified in 10.2.13 -main.update_innodb : Modified in 10.2.13 main.userstat : MDEV-12904 - SSL errors -main.view : Modified in 10.2.14 +main.variables : Modified in 10.2.15 +main.view : Modified in 10.2.15 main.warnings : Modified in 10.2.14 -main.win : Modified in 10.2.13 +main.win : Modified in 10.2.15 main.xa : Modified in 10.2.14 -main.xml : Modified in 10.2.13 #---------------------------------------------------------------- @@ -149,6 +146,7 @@ binlog_encryption.rpl_skip_replication : MDEV-13571 - Unexpected warning binlog_encryption.rpl_ssl : MDEV-14507 - Timeouts binlog_encryption.rpl_stm_relay_ign_space : MDEV-13278 - Wrong result (test assertion) binlog_encryption.rpl_sync : MDEV-13830 - Assertion failure +binlog_encryption.rpl_typeconv : Include file modified in 10.2.15 #---------------------------------------------------------------- @@ -164,28 +162,26 @@ disks.disks : Added in 10.2.14 #---------------------------------------------------------------- -encryption.create_or_replace : MDEV-9359, MDEV-13516 - Assertion failure, MDEV-12694 - Timeout -encryption.debug_key_management : MDEV-13841 - Timeout; modified in 10.2.13 +encryption.create_or_replace : MDEV-12694 - Timeout; MDEV-16115 - Trying to access tablespace +encryption.debug_key_management : MDEV-13841 - Timeout encryption.encrypt_and_grep : MDEV-13765 - Wrong result; modified in 10.2.14 encryption.innochecksum : MDEV-13644 - Assertion failure encryption.innodb-bad-key-change : Modified in 10.2.14 encryption.innodb-compressed-blob : MDEV-14728 - Unable to get certificate -encryption.innodb-discard-import-change : MDEV-12632 - Valgrind encryption.innodb_encrypt_log : MDEV-13725 - Wrong result encryption.innodb_encryption : MDEV-15675 - Timeout; modified in 10.2.14 encryption.innodb-encryption-alter : MDEV-13566 - Lock wait timeout -encryption.innodb_encryption_discard_import : MDEV-12903 - Wrong result, MDEV-14045 - Error 192 -encryption.innodb_encryption_filekeys : MDEV-15673 - Timeout; modified in 10.2.14 +encryption.innodb_encryption_discard_import : MDEV-16116 - Wrong result; modified in 10.2.15 +encryption.innodb_encryption_filekeys : MDEV-15673 - Timeout; modified in 10.2.15 encryption.innodb_encryption-page-compression : MDEV-12630 - crash or assertion failure; modified in 10.2.14 -encryption.innodb_encryption_tables : MDEV-9359 - Assertion failure +encryption.innodb_encryption_row_compressed : MDEV-16113 - Crash encryption.innodb-first-page-read : MDEV-14356 - Timeout in wait condition -encryption.innodb_lotoftables : MDEV-11531 - Operation on a dropped tablespace -encryption.innodb-missing-key : MDEV-9359 - assertion failure -encryption.innodb-redo-badkey : MDEV-13893 - Page cannot be decrypted -encryption.innodb-redo-nokeys : Modified in 10.2.14 +encryption.innodb_lotoftables : Modified in 10.2.15 +encryption.innodb-redo-badkey : MDEV-13893 - Page cannot be decrypted; include file modified in 10.2.15 +encryption.innodb-redo-nokeys : Include file modified in 10.2.15 +encryption.innodb-remove-encryption : Added in 10.2.15 encryption.innodb_scrub_background : Modified in 10.2.14 encryption.innodb-spatial-index : MDEV-13746 - Wrong result; modified in 10.2.14 -encryption.tempfiles : Modified in 10.2.13 #---------------------------------------------------------------- @@ -202,6 +198,8 @@ federated.federatedx : MDEV-10617 - Wrong checksum #---------------------------------------------------------------- +funcs_1.processlist_val_no_prot : MDEV-11223 - Wrong result + funcs_2/charset.* : MDEV-10999 - Not maintained #---------------------------------------------------------------- @@ -211,96 +209,93 @@ galera_3nodes.* : Suite is not stable yet #---------------------------------------------------------------- -gcol.innodb_virtual_debug_purge : Modified in 10.2.13 +gcol.innodb_virtual_fk : Modified in 10.2.15 +gcol.innodb_virtual_index : Modified in 10.2.15 #---------------------------------------------------------------- innodb.101_compatibility : MDEV-13891 - Wrong result -innodb.alter_copy : Added in 10.2.13 +innodb.alter_copy : MDEV-16181 - Assertion failure +innodb.alter_missing_tablespace : Modified in 10.2.15 +innodb.alter_partitioned_debug : Added in 10.2.15 +innodb.alter_partitioned_xa : Added in 10.2.15 innodb.autoinc_persist : MDEV-15282 - Assertion failure -innodb.deadlock_detect : Modified in 10.2.13 innodb.default_row_format_alter : Added in 10.2.14 innodb.default_row_format_compatibility : Added in 10.2.14 innodb.default_row_format_create : Added in 10.2.14 -innodb.doublewrite : MDEV-12905 - Server crash +innodb.doublewrite : MDEV-12905 - Server crash; include file modified in 10.2.15 innodb.file_format_defaults : Added in 10.2.14 -innodb.foreign_key : Modified in 10.2.13 +innodb.foreign_key : Modified in 10.2.15 innodb.group_commit_crash : MDEV-14191 - InnoDB registration failed innodb.group_commit_crash_no_optimize_thread : MDEV-13830 - Assertion failure -innodb.innodb : Modified in 10.2.13 +innodb.innodb-64k-crash : MDEV-13872 - Failure and crash on startup +innodb.innodb-alter : Modified in 10.2.15 +innodb.innodb-alter-nullable : Modified in 10.2.15 innodb.innodb-alter-tempfile : MDEV-15285 - Table already exists -innodb.innodb_bug14147491 : MDEV-11808 - Index is corrupt; modified in 10.2.13 +innodb.innodb_bug14147491 : MDEV-11808 - Index is corrupt +innodb.innodb_bug27216817 : Added in 10.2.15 innodb.innodb_bug30423 : MDEV-7311 - Wrong result innodb.innodb_bug48024 : MDEV-14352 - Assertion failure innodb.innodb_bug59641 : MDEV-13830 - Assertion failure -innodb.innodb_buffer_pool_resize : Added in 10.2.13 -innodb.innodb_buffer_pool_resize_with_chunks : Added in 10.2.13 innodb.innodb_bulk_create_index_replication : MDEV-15273 - Slave failed to start -innodb.innodb_corrupt_bit : Modified in 10.2.13 innodb.innodb_defrag_stats_many_tables : MDEV-14198 - Table is full innodb.innodb-get-fk : MDEV-13276 - Server crash -innodb.innodb-index-online : MDEV-14809 - Cannot save statistics; modified in 10.2.13 +innodb.innodb-index : Modified in 10.2.15 +innodb.innodb-index-online : MDEV-14809 - Cannot save statistics innodb.innodb_information_schema : MDEV-8851 - Wrong result -innodb.innodb-lru-force-no-free-page : Added in 10.2.13 +innodb.innodb-isolation : Modified in 10.2.15 innodb.innodb_max_recordsize_32k : MDEV-14801 - Operation failed innodb.innodb_max_recordsize_64k : MDEV-15203 - Wrong result innodb.innodb-page_compression_default : MDEV-13644 - Assertion failure innodb.innodb-page_compression_lzma : MDEV-14353 - Wrong result -innodb.innodb-replace-debug : Modified in 10.2.13 -innodb.innodb_stats_drop_locked : Modified in 10.2.13 +innodb.innodb_prefix_index_restart_server : Modified in 10.2.15 innodb.innodb_stats_persistent_debug : MDEV-14801 - Operation failed innodb.innodb-table-online : MDEV-13894 - Wrong result innodb.innodb_sys_semaphore_waits : MDEV-10331 - Semaphore wait innodb.innodb-wl5522-debug : MDEV-14200 - Wrong errno innodb.innodb_zip_innochecksum2 : MDEV-13882 - Extra warnings innodb.innodb_zip_innochecksum3 : MDEV-14486 - Resource temporarily unavailable -innodb.log_corruption : MDEV-13251 - Wrong result; modified in 10.2.13 -innodb.log_data_file_size : MDEV-14204 - Server failed to start -innodb.log_file_name : MDEV-14193 - Exception; MDEV-15325 - Assertion failure -innodb.log_file_size : MDEV-15668 - Not found pattern; modified in 10.2.13 -innodb.mvcc : Added in 10.2.13 +innodb.log_alter_table : Include file modified in 10.2.15 +innodb.log_corruption : MDEV-13251 - Wrong result +innodb.log_data_file_size : MDEV-14204 - Server failed to start; include file modified in 10.2.15 +innodb.log_file_name : MDEV-14193 - Exception; include file modified in 10.2.15 +innodb.log_file_name_debug : Include file modified in 10.2.15 +innodb.log_file_size : MDEV-15668 - Not found pattern +innodb.mdev-15707 : Added in 10.2.15 +innodb.monitor : MDEV-16179 - Wrong result innodb.purge_secondary : MDEV-15681 - Wrong result; modified in 10.2.14 innodb.purge_thread_shutdown : MDEV-13792 - Wrong result -innodb.read_only_recovery : MDEV-13886 - Server crash; modified in 10.2.13 +innodb.read_only_recovery : MDEV-13886 - Server crash innodb.read_only_recover_committed : Added in 10.2.14 -innodb.recovery_shutdown : MDEV-15671 - Checksum mismatch in datafile; modified in 10.2.13 +innodb.recovery_shutdown : MDEV-15671 - Checksum mismatch in datafile innodb.restart : Added in 10.2.14 innodb.row_format_redundant : MDEV-15192 - Trying to access missing tablespace -innodb.table_definition_cache_debug : MDEV-14206 - Extra warning; opt file modified in 10.2.13 +innodb.stored_fk : Added in 10.2.15 +innodb.table_definition_cache_debug : MDEV-14206 - Extra warning innodb.table_flags : MDEV-13572 - Wrong result -innodb.temporary_table : MDEV-13265 - Wrong result -innodb.truncate_inject : Added in 10.2.13 -innodb.update-cascade : Added in 10.2.13 +innodb.temp_table_savepoint : MDEV-16182 - Wrong result +innodb.temporary_table : MDEV-13265 - Wrong result; modified in 10.2.15 +innodb.undo_log : Modified in 10.2.15 innodb.update_time : MDEV-14804 - Wrong result innodb.xa_recovery : MDEV-15279 - mysqld got exception +innodb_fts.basic : Added in 10.2.15 innodb_fts.fulltext2 : MDEV-14727 - Long semaphore wait innodb_fts.fulltext_misc : MDEV-12636 - Valgrind +innodb_fts.fulltext_table_evict : Added in 10.2.15 innodb_fts.innodb_fts_plugin : MDEV-13888 - Errors in server log innodb_fts.innodb_fts_stopword_charset : MDEV-13259 - Table crashed innodb_fts.sync : MDEV-14808 - Wrong result -innodb_gis.bug17057168 : Re-enabled in 10.2.13 -innodb_gis.geometry : Modified in 10.2.13 -innodb_gis.gis_split_inf : Modified in 10.2.13 -innodb_gis.innodb_gis_rtree : Added in 10.2.13 -innodb_gis.rtree_compress : Modified in 10.2.13 -innodb_gis.rtree_compress2 : Modified in 10.2.13 -innodb_gis.rtree_concurrent_srch : MDEV-15284 - Wrong result with embedded; modified in 10.2.13 -innodb_gis.rtree_debug : Modified in 10.2.13 -innodb_gis.rtree_estimate : Re-enabled in 10.2.13 -innodb_gis.rtree_multi_pk : Re-enabled in 10.2.13 -innodb_gis.rtree_purge : MDEV-15275 - Timeout; modified in 10.2.13 -innodb_gis.rtree_recovery : MDEV-15274 - Error on check; re-enabled in 10.2.13 -innodb_gis.rtree_search : Modified in 10.2.13 -innodb_gis.rtree_split : MDEV-14208 - Too many arguments; modified in 10.2.13 -innodb_gis.rtree_undo : MDEV-14456 - Timeout in include file; modified in 10.2.13 -innodb_gis.tree_search : Re-enabled in 10.2.13 -innodb_gis.types : MDEV-15679 - Table is marked as crashed; modified in 10.2.13 +innodb_gis.rtree_concurrent_srch : MDEV-15284 - Wrong result with embedded +innodb_gis.rtree_purge : MDEV-15275 - Timeout +innodb_gis.rtree_recovery : MDEV-15274 - Error on check +innodb_gis.rtree_split : MDEV-14208 - Too many arguments +innodb_gis.rtree_undo : MDEV-14456 - Timeout in include file +innodb_gis.types : MDEV-15679 - Table is marked as crashed; modified in 10.2.15 -innodb_zip.cmp_per_index : MDEV-14490 - Table is marked as crashed +innodb_zip.cmp_per_index : MDEV-14490 - Table is marked as crashed; modified in 10.2.15 innodb_zip.innochecksum_3 : MDEV-13279 - Extra warnings -innodb_zip.prefix_index_liftedlimit : Added in 10.2.13 innodb_zip.wl6470_1 : MDEV-14240 - Assertion failure innodb_zip.wl6501_1 : MDEV-10891 - Can't create UNIX socket innodb_zip.wl5522_debug_zip : MDEV-11600 - Operating system error number 2 @@ -310,27 +305,24 @@ innodb_zip.wl6501_scale_1 : MDEV-13254 - Timeout, MDEV-14104 - Error maria.dynamic : Added in 10.2.14 maria.insert_select : MDEV-12757 - Timeout -maria.lock : Modified in 10.2.13 -maria.maria : MDEV-14430 - Extra warning; modified in 10.2.13 -maria.max_length : Modified in 10.2.13 -maria.repair : Added in 10.2.13 +maria.maria : MDEV-14430 - Extra warning #---------------------------------------------------------------- -mariabackup.apply-log-only : MDEV-14192 - Assertion failure; modified in 10.2.13 -mariabackup.apply-log-only-incr : MDEV-14192 - Assertion failure; modified in 10.2.13 +mariabackup.absolute_ibdata_paths : Added in 10.2.15 +mariabackup.apply-log-only : MDEV-14192 - Assertion failure +mariabackup.apply-log-only-incr : MDEV-14192 - Assertion failure +mariabackup.backup_ssl : Added in 10.2.15 mariabackup.data_directory : MDEV-15270 - Error on exec mariabackup.extra_lsndir : Added in 10.2.14 -mariabackup.huge_lsn : Modified in 10.2.13 mariabackup.incremental_backup : MDEV-14192 - Assertion failure mariabackup.incremental_encrypted : MDEV-14188 - Wrong result, MDEV-15667 - timeout mariabackup.mdev-14447 : MDEV-15201 - Timeout -mariabackup.missing_ibd : Added in 10.2.13 mariabackup.partial_exclude : MDEV-15270 - Error on exec mariabackup.undo_space_id : Added in 10.2.14 -mariabackup.unsupported_redo : MDEV-15682 - Wrong result code; added in 10.2.14 +mariabackup.unsupported_redo : Modified in 10.2.15 mariabackup.xbstream : MDEV-14192 - Crash -mariabackup.xb_aws_key_management : MDEV-15680 - Error: xtrabackup_copy_logfile() failed; modified in 10.2.13 +mariabackup.xb_aws_key_management : MDEV-15680 - Error: xtrabackup_copy_logfile() failed mariabackup.xb_page_compress : MDEV-14810 - status: 1, errno: 11 mariabackup.xb_compressed_encrypted : MDEV-14812 - Segmentation fault @@ -347,11 +339,12 @@ multi_source.simple : MDEV-4633 - Wrong result #---------------------------------------------------------------- -parts.partition_alter_maria : Modified in 10.2.14 -parts.partition_alter_myisam : Modified in 10.2.14 +parts.partition_alter_innodb : Include file modified in 10.2.15 +parts.partition_alter_maria : Include file modified in 10.2.15 +parts.partition_alter_myisam : Include file modified in 10.2.15 parts.partition_auto_increment_maria : MDEV-14430 - Extra warning -parts.partition_basic_symlink_innodb : Modified in 10.2.13 parts.partition_debug_innodb : MDEV-10891 - Can't create UNIX socket; MDEV-15095 - Table doesn't exist +parts.show_create : Added in 10.2.15 #---------------------------------------------------------------- @@ -364,8 +357,10 @@ perfschema.bad_option_3 : MDEV-12728 - Timeout on Power perfschema.bad_option_5 : MDEV-14197 - Timeout perfschema.dml_file_instances : MDEV-15179 - Wrong result perfschema.hostcache_ipv4_addrinfo_again_allow : MDEV-12759 - Crash +perfschema.hostcache_ipv4_max_con : Modified in 10.2.15 perfschema.hostcache_ipv6_addrinfo_again_allow : MDEV-12752 - Crash perfschema.hostcache_ipv6_addrinfo_bad_allow : MDEV-13260 - Crash +perfschema.hostcache_ipv6_max_con : Modified in 10.2.15 perfschema.hostcache_ipv6_ssl : MDEV-10696 - Crash perfschema.setup_actors : MDEV-10679 - Crash perfschema.socket_connect : MDEV-15677 - Wrong result @@ -380,7 +375,7 @@ perfschema_stress.* : MDEV-10996 - Not maintained #---------------------------------------------------------------- plugins.feedback_plugin_send : MDEV-7932, MDEV-11118 - Connection problems and such -plugins.server_audit : Modified in 10.2.14 +plugins.server_audit : Modified in 10.2.15 plugins.thread_pool_server_audit : MDEV-14295 - Wrong result #---------------------------------------------------------------- @@ -392,6 +387,7 @@ rocksdb_sys_vars.* : Tests are unstable rpl.rpl_binlog_errors : MDEV-12742 - Crash rpl.rpl_binlog_index : MDEV-9501 - Failed registering on master +rpl.rpl_colSize : MDEV-16112 - Server crash rpl.rpl_ctype_latin1 : MDEV-14813 - Wrong result on Mac rpl.rpl_domain_id_filter_io_crash : MDEV-12729 - Timeout in include file, MDEV-13677 - Server crash rpl.rpl_domain_id_filter_restart : MDEV-10684 - Wrong result @@ -408,20 +404,22 @@ rpl.rpl_mixed_mixing_engines : MDEV-14489 - Sync slave with master faile rpl.rpl_non_direct_mixed_mixing_engines : MDEV-14489 - Sync slave with master failed rpl.rpl_non_direct_row_mixing_engines : MDEV-14491 - Long semaphore wait rpl.rpl_non_direct_stm_mixing_engines : MDEV-14489 - Failed sync_slave_with_master +rpl.rpl_parallel : MDEV-10653 - Timeouts rpl.rpl_parallel_conflicts : MDEV-15272 - Server crash rpl.rpl_parallel_mdev6589 : MDEV-12979 - Assertion failure rpl.rpl_parallel_optimistic : MDEV-15278 - Failed to sync with master rpl.rpl_parallel_optimistic_nobinlog : MDEV-15278 - Failed to sync with master rpl.rpl_parallel_retry : MDEV-11119 - Crash; modified in 10.2.14 rpl.rpl_parallel_temptable : MDEV-10356 - Crash +rpl.rpl_row_basic_2myisam : MDEV-13875 - command "diff_files" failed rpl.rpl_row_drop_create_temp_table : MDEV-14487 - Wrong result rpl.rpl_row_img_eng_min : MDEV-13875 - diff_files failed +rpl.rpl_row_img_eng_noblob : MDEV-13875 - command "diff_files" failed rpl.rpl_row_index_choice : MDEV-15196 - Slave crash rpl.rpl_row_mixing_engines : MDEV-14491 - Long semaphore wait rpl.rpl_semi_sync : MDEV-11220 - Wrong result rpl.rpl_semi_sync_after_sync : MDEV-14366 - Wrong result rpl.rpl_semi_sync_after_sync_row : MDEV-14366 - Wrong result -rpl.rpl_semi_sync_skip_repl : Added in 10.2.13 rpl.rpl_semi_sync_uninstall_plugin : MDEV-7140 - Assorted failures rpl.rpl_set_statement_default_master : MDEV-13258 - Extra warning rpl.rpl_show_slave_hosts : MDEV-10681 - Crash @@ -431,12 +429,16 @@ rpl.rpl_slave_load_tmpdir_not_exist : MDEV-14203 - Extra warning rpl.rpl_slow_query_log : MDEV-13250 - Test abort rpl.rpl_sp_effects : MDEV-13249 - Crash rpl.rpl_start_stop_slave : MDEV-13567 - Sync slave timeout +rpl.rpl_mixed_implicit_commit_binlog : Include file modified in 10.2.15 +rpl.rpl_row_implicit_commit_binlog : Include file modified in 10.2.15 +rpl.rpl_stm_implicit_commit_binlog : Include file modified in 10.2.15 rpl.rpl_stm_mixing_engines : MDEV-14489 - Sync slave with master failed rpl.rpl_stm_multi_query : MDEV-9501 - Failed registering on master rpl.rpl_stm_relay_ign_space : MDEV-14360 - Test assertion rpl.rpl_stm_stop_middle_group : MDEV-13791 - Server crash rpl.rpl_sync : MDEV-13830 - Assertion failure rpl.rpl_temporal_mysql56_to_mariadb53 : MDEV-9501 - Failed registering on master +rpl.rpl_typeconv : Include file modified in 10.2.15 rpl.rpl_upgrade_master_info : MDEV-11620 - Table marked as crashed rpl.sec_behind_master-5114 : MDEV-13878 - Wrong result @@ -447,7 +449,7 @@ rpl/extra/rpl_tests.* : MDEV-10994 - Not maintained spider.basic_sql : MDEV-11186 - Internal check fails spider/bg.direct_aggregate : MDEV-7098 - Packets out of order -spider/bg.ha_part : MDEV-7914 - Crash +spider/bg.ha_part : MDEV-7914 - Crash (only fixed in 10.3) spider/bg.spider3_fixes : MDEV-12639 - Syntax error spider/handler.* : MDEV-10990 - Not maintained @@ -464,34 +466,34 @@ storage_engine.* : Not always timely maintained #---------------------------------------------------------------- sys_vars.innodb_buffer_pool_dump_at_shutdown_basic : MDEV-14280 - Unexpected error -sys_vars.innodb_print_lock_wait_timeout_info_basic : Added in 10.2.13 +sys_vars.max_prepared_stmt_count_basic : Modified in 10.2.15 sys_vars.rpl_init_slave_func : MDEV-10149 - Test assertion sys_vars.slow_query_log_func : MDEV-14273 - Wrong result +sys_vars.sysvars_innodb : Opt file modified in 10.2.15 +sys_vars.sysvars_server_embedded : Opt file added in 10.2.15 +sys_vars.sysvars_server_notembedded : Opt file added in 10.2.15 sys_vars.thread_cache_size_func : MDEV-11775 - Wrong result sys_vars.wsrep_sst_receive_address_basic : Modified in 10.2.14 #---------------------------------------------------------------- -tokudb.card_scale_percent : Modified in 10.2.13 tokudb.change_column_all_1000_10 : MDEV-12640 - Lost connection tokudb.change_column_bin : MDEV-12640 - Lost connection tokudb.change_column_char : MDEV-12822 - Lost connection tokudb.dir_per_db : MDEV-11537 - Wrong result +tokudb.hotindex-insert-0 : MDEV-15271 - Timeout tokudb.hotindex-insert-2 : MDEV-15271 - Timeout tokudb.hotindex-insert-bigchar : MDEV-12640 - Crash tokudb.hotindex-update-0 : MDEV-15198 - Timeout tokudb.hotindex-update-1 : MDEV-12640 - Crash -tokudb.locking-read-repeatable-read-1 : Added in 10.2.13 -tokudb.locking-read-repeatable-read-2 : Added in 10.2.13 -tokudb.nonflushing_analyze_debug : Added in 10.2.13 tokudb.rows-32m-rand-insert : MDEV-12640 - Crash tokudb.rows-32m-seq-insert : MDEV-12640 - Crash -tokudb.row_format : Modified in 10.2.13 tokudb.savepoint-5 : MDEV-15280 - Wrong result tokudb.type_datetime : MDEV-15193 - Wrong result tokudb_alter_table.hcad_all_add2 : MDEV-15269 - Timeout +tokudb_bugs.db917 : Modified in 10.2.15 tokudb_bugs.xa : MDEV-11804 - Lock wait timeout tokudb_backup.* : MDEV-11001 - Missing include file @@ -500,12 +502,8 @@ tokudb_rpl.* : MDEV-11001 - Missing include file tokudb_mariadb.mdev6657 : Modified in 10.2.14 -tokudb_parts.nonflushing_analyze_debug : Added in 10.2.13 tokudb_parts.partition_alter4_tokudb : MDEV-12640 - Lost connection -tokudb_perfschema.crash_tokudb : Added in 10.2.13 -tokudb_perfschema.start_server_tokudb : Added in 10.2.13 - #---------------------------------------------------------------- unit.conc_basic-t : MDEV-15286 - not ok 7 - test_reconnect_maxpackage @@ -516,6 +514,10 @@ unit.my_atomic : MDEV-15670 - Signal 11 thrown #---------------------------------------------------------------- +vcol.partition : Modified in 10.2.15 + +#---------------------------------------------------------------- + wsrep.binlog_format : MDEV-11532 - Could not execute check-testcase wsrep.foreign_key : MDEV-14725 - WSREP has not yet prepared node wsrep.mdev_6832 : MDEV-14195 - Check testcase failed From 6f4534e6220d9224dbd3226aba310c4ca58f6da3 Mon Sep 17 00:00:00 2001 From: Varun Gupta Date: Tue, 15 May 2018 01:44:03 +0530 Subject: [PATCH 23/33] MDEV-14695: Assertion `n < m_size' failed in Bounds_checked_array::operator In this issue we hit the assert because we are adding addition fields to the field JOIN::all_fields list. This is done because HEAP tables can't index BIT fields so we need to use an additional hidden field for grouping because later it will be converted to a LONG field. Original field will remain of the BIT type and will be returned. This happens when we convert DISTINCT to GROUP BY. The solution is to take into account the number of such hidden fields that would be added to the field JOIN::all_fields list while calculating the size of the ref_pointer_array. --- mysql-test/r/distinct.result | 10 ++++++++++ mysql-test/t/distinct.test | 8 ++++++++ sql/sql_base.cc | 9 ++++++--- sql/sql_base.h | 5 +++-- sql/sql_delete.cc | 3 ++- sql/sql_lex.cc | 8 +++++++- sql/sql_lex.h | 5 +++++ sql/sql_select.cc | 4 +++- sql/sql_union.cc | 1 + 9 files changed, 45 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/distinct.result b/mysql-test/r/distinct.result index 8d7074cd270..e1bbf5adb79 100644 --- a/mysql-test/r/distinct.result +++ b/mysql-test/r/distinct.result @@ -1039,4 +1039,14 @@ count(distinct case when id<=63 then id end) 63 drop table tb; SET @@tmp_table_size= @tmp_table_size_save; +# +# MDEV-14695: Assertion `n < m_size' failed in Bounds_checked_array::operator +# +CREATE TABLE t1 (b1 BIT, b2 BIT, b3 BIT, b4 BIT , b5 BIT, b6 BIT); +INSERT INTO t1 VALUES (1,0,0,1,0,1),(0,1,0,0,1,0); +SELECT DISTINCT b1+'0', b2+'0', b3+'0', b4+'0', b5+'0', b6 +'0' FROM t1; +b1+'0' b2+'0' b3+'0' b4+'0' b5+'0' b6 +'0' +1 0 0 1 0 1 +0 1 0 0 1 0 +DROP TABLE t1; End of 5.5 tests diff --git a/mysql-test/t/distinct.test b/mysql-test/t/distinct.test index 7cf3d6810bb..c11f8b501bc 100644 --- a/mysql-test/t/distinct.test +++ b/mysql-test/t/distinct.test @@ -790,4 +790,12 @@ drop table tb; SET @@tmp_table_size= @tmp_table_size_save; +--echo # +--echo # MDEV-14695: Assertion `n < m_size' failed in Bounds_checked_array::operator +--echo # + +CREATE TABLE t1 (b1 BIT, b2 BIT, b3 BIT, b4 BIT , b5 BIT, b6 BIT); +INSERT INTO t1 VALUES (1,0,0,1,0,1),(0,1,0,0,1,0); +SELECT DISTINCT b1+'0', b2+'0', b3+'0', b4+'0', b5+'0', b6 +'0' FROM t1; +DROP TABLE t1; --echo End of 5.5 tests diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 95ff41cb6f4..4ba74804a05 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -6919,7 +6919,7 @@ static bool setup_natural_join_row_types(THD *thd, int setup_wild(THD *thd, TABLE_LIST *tables, List &fields, List *sum_func_list, - uint wild_num) + uint wild_num, uint *hidden_bit_fields) { if (!wild_num) return(0); @@ -6960,7 +6960,7 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List &fields, else if (insert_fields(thd, ((Item_field*) item)->context, ((Item_field*) item)->db_name, ((Item_field*) item)->table_name, &it, - any_privileges)) + any_privileges, hidden_bit_fields)) { if (arena) thd->restore_active_arena(arena, &backup); @@ -7425,7 +7425,7 @@ bool get_key_map_from_key_list(key_map *map, TABLE *table, bool insert_fields(THD *thd, Name_resolution_context *context, const char *db_name, const char *table_name, List_iterator *it, - bool any_privileges) + bool any_privileges, uint *hidden_bit_fields) { Field_iterator_table_ref field_iterator; bool found; @@ -7545,6 +7545,9 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name, else it->after(item); /* Add 'item' to the SELECT list. */ + if (item->type() == Item::FIELD_ITEM && item->field_type() == MYSQL_TYPE_BIT) + (*hidden_bit_fields)++; + #ifndef NO_EMBEDDED_ACCESS_CHECKS /* Set privilege information for the fields of newly created views. diff --git a/sql/sql_base.h b/sql/sql_base.h index d6063f1b771..c59a24e4272 100644 --- a/sql/sql_base.h +++ b/sql/sql_base.h @@ -154,11 +154,12 @@ bool fill_record_n_invoke_before_triggers(THD *thd, TABLE *table, enum trg_event_type event); bool insert_fields(THD *thd, Name_resolution_context *context, const char *db_name, const char *table_name, - List_iterator *it, bool any_privileges); + List_iterator *it, bool any_privileges, + uint *hidden_bit_fields); void make_leaves_list(THD *thd, List &list, TABLE_LIST *tables, bool full_table_list, TABLE_LIST *boundary); int setup_wild(THD *thd, TABLE_LIST *tables, List &fields, - List *sum_func_list, uint wild_num); + List *sum_func_list, uint wild_num, uint * hidden_bit_fields); bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array, List &item, enum_mark_columns mark_used_columns, List *sum_func_list, List *pre_fix, diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 7b7a7e3f804..48509a46ccb 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -760,7 +760,8 @@ l select_lex->leaf_tables, FALSE, DELETE_ACL, SELECT_ACL, TRUE)) DBUG_RETURN(TRUE); - if ((wild_num && setup_wild(thd, table_list, field_list, NULL, wild_num)) || + if ((wild_num && setup_wild(thd, table_list, field_list, NULL, wild_num, + &select_lex->hidden_bit_fields)) || setup_fields(thd, Ref_ptr_array(), field_list, MARK_COLUMNS_READ, NULL, NULL, 0) || setup_conds(thd, table_list, select_lex->leaf_tables, conds) || diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 3e36cac96b9..1752689b385 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -2126,6 +2126,7 @@ void st_select_lex::init_query() select_n_having_items= 0; n_sum_items= 0; n_child_sum_items= 0; + hidden_bit_fields= 0; subquery_in_having= explicit_limit= 0; is_item_list_lookup= 0; first_execution= 1; @@ -2673,6 +2674,10 @@ ulong st_select_lex::get_table_join_options() bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num) { + + if (!((options & SELECT_DISTINCT) && !group_list.elements)) + hidden_bit_fields= 0; + // find_order_in_list() may need some extra space, so multiply by two. order_group_num*= 2; @@ -2687,7 +2692,8 @@ bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num) select_n_reserved + select_n_having_items + select_n_where_fields + - order_group_num) * 5; + order_group_num + + hidden_bit_fields) * 5; if (!ref_pointer_array.is_null()) { /* diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 6d281930d1f..68e1885f5e9 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -862,6 +862,11 @@ public: uint select_n_where_fields; /* reserved for exists 2 in */ uint select_n_reserved; + /* + it counts the number of bit fields in the SELECT list. These are used when DISTINCT is + converted to a GROUP BY involving BIT fields. + */ + uint hidden_bit_fields; enum_parsing_place parsing_place; /* where we are parsing expression */ enum_parsing_place context_analysis_place; /* where we are in prepare */ bool with_sum_func; /* sum function indicator */ diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 4cd4754596b..1d5abd6a36f 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -799,7 +799,9 @@ JOIN::prepare(TABLE_LIST *tables_init, select_lex != select_lex->master_unit()->global_parameters()) real_og_num+= select_lex->order_list.elements; - if (setup_wild(thd, tables_list, fields_list, &all_fields, wild_num)) + DBUG_ASSERT(select_lex->hidden_bit_fields == 0); + if (setup_wild(thd, tables_list, fields_list, &all_fields, wild_num, + &select_lex->hidden_bit_fields)) DBUG_RETURN(-1); if (select_lex->setup_ref_array(thd, real_og_num)) DBUG_RETURN(-1); diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 3fe8a24f8bd..3fe90564000 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -1474,6 +1474,7 @@ bool st_select_lex::cleanup() } inner_refs_list.empty(); exclude_from_table_unique_test= FALSE; + hidden_bit_fields= 0; DBUG_RETURN(error); } From ac2410f6d89f20a3d7de61dba9cdf433bff8d426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 11 Aug 2014 10:43:11 +0300 Subject: [PATCH 24/33] Bug#19330255 WL#7142 - CRASH DURING ALTER TABLE LEADS TO DATA DICTIONARY INCONSISTENCY The server crashes on a SELECT because of space id mismatch. The mismatch happens if the server crashes during an ALTER TABLE. There are actually two cases of inconsistency, and three fixes needed for the InnoDB problems. We have dictionary data (tablespace or table name) in 3 places: (a) The *.frm file is for the old table definition. (b) The InnoDB data dictionary is for the new table definition. (c) The file system did not rename the tablespace files yet. In this fix, we will not care if the *.frm file is in sync with the InnoDB data dictionary and file system. We will concentrate on the mismatch between (b) and (c). Two scenarios have been mentioned in this bug report. The simpler one first: 1. The changes to SYS_TABLES were committed, and MLOG_FILE_RENAME2 records were written in a single mini-transaction commit. The files were not yet renamed in the file system. 2a. The server is killed, without making a log checkpoint. 3a. The server refuses to start up, because replaying MLOG_FILE_RENAME2 fails. I failed to repeat this myself. I repeated step 3a with a saved dataset. The problem seems to be that MLOG_FILE_RENAME2 replay is incorrectly being skipped when there is no page-redo log or MLOG_FILE_NAME record for the old name of the tablespace. FIX#1: Recover the id-to-name mapping also from MLOG_FILE_RENAME2 records when scanning the redo log. It is not necessary to write MLOG_FILE_NAME records in addition to MLOG_FILE_RENAME2 records for renaming tablespace files. The scenario in the original Description involves a log checkpoint: 1. The changes to SYS_TABLES were committed, and MLOG_FILE_RENAME2 records were written in a single mini-transaction commit. 2. A log checkpoint and a server kill was injected. 3. Crash recovery will see no records (other than the MLOG_CHECKPOINT). 4. dict_check_tablespaces_and_store_max_id() will emit a message about a non-found table #sql-ib22*. 5. A mismatch is triggering the assertion failure. In my test, at step 4 the SYS_TABLES root page (0:8) contains these 3 records right before the page supremum: * delete-marked (committed) name=#sql-ib21* record, with space=10. * name=#sql-ib22*, space=9. * name=t1, space=10. space=10 is the rebuilt table (#sql-ib21*.ibd in the file system). space=9 is the old table (t1.ibd in the file system). The function dict_check_tablespaces_and_store_max_id() will enter t1.ibd with space_id=10 into the fil_system cache without noticing that t1.ibd contains space_id=9, because it invokes fil_open_single_table_tablespace() with validate=false. In MySQL 5.6, the space_id from all *.ibd files are being read when the redo log checkpoint LSN disagrees with the FIL_PAGE_FILE_FLUSH_LSN in the system tablespace. This field is only updated during a clean shutdown, after performing the final log checkpoint. FIX#2: dict_check_tablespaces_and_store_max_id() should pass validate=true to fil_open_single_table_tablespace() when a non-clean shutdown is detected, forcing the first page of each *.ibd file to be read. (We do not want to slow down startup after a normal shutdown.) With FIX#2, the SELECT would fail to find the table. This would introduce a regression, because before WL#7142, a copy of the table was accessible after recovery. FIX#3: Maintain a list of MLOG_FILE_RENAME2 records that have been written to the redo log, but not performed yet in the file system. When performing a checkpoint, re-emit these records to the redo log. In this way, a mismatch between (b) and (c) should be impossible. fil_name_process(): Refactored from fil_name_parse(). Adds an item to the id-to-filename mapping. fil_name_parse(): Parses and applies a MLOG_FILE_NAME, MLOG_FILE_DELETE or MLOG_FILE_RENAME2 record. This implements FIX#1. fil_name_write_rename(): A wrapper function for writing MLOG_FILE_RENAME2 records. fil_op_replay_rename(): Apply MLOG_FILE_RENAME2 records. Replaces fil_op_log_parse_or_replay(), whose logic was moved to fil_name_parse(). fil_tablespace_exists_in_mem(): Return fil_space_t* instead of bool. dict_check_tablespaces_and_store_max_id(): Add the parameter "validate" to implement FIX#2. log_sys->append_on_checkpoint: Extra log records to append in case of a checkpoint. Needed for FIX#3. log_append_on_checkpoint(): New function, to update log_sys->append_on_checkpoint. mtr_write_log(): New function, to append mtr_buf_t to the redo log. fil_names_clear(): Append the data from log_sys->append_on_checkpoint if needed. ha_innobase::commit_inplace_alter_table(): Add any MLOG_FILE_RENAME2 records to log_sys->append_on_checkpoint(), and remove them once the files have been renamed in the file system. mtr_buf_copy_t: A helper functor for copying a mini-transaction log. rb#6282 approved by Jimmy Yang --- mysql-test/suite/innodb/r/alter_kill.result | 76 ++++++++ .../suite/innodb/t/alter_kill-master.opt | 1 + mysql-test/suite/innodb/t/alter_kill.test | 174 ++++++++++++++++++ 3 files changed, 251 insertions(+) create mode 100644 mysql-test/suite/innodb/r/alter_kill.result create mode 100644 mysql-test/suite/innodb/t/alter_kill-master.opt create mode 100644 mysql-test/suite/innodb/t/alter_kill.test diff --git a/mysql-test/suite/innodb/r/alter_kill.result b/mysql-test/suite/innodb/r/alter_kill.result new file mode 100644 index 00000000000..bdba057acef --- /dev/null +++ b/mysql-test/suite/innodb/r/alter_kill.result @@ -0,0 +1,76 @@ +# +# Bug#16720368 INNODB CRASHES ON BROKEN #SQL*.IBD FILE AT STARTUP +# +SET GLOBAL innodb_file_per_table=1; +CREATE TABLE bug16720368_1 (a INT PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE bug16720368 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB; +INSERT INTO bug16720368 (a) VALUES (1),(2),(3),(4),(5),(6),(7),(8); +# Cleanly shutdown mysqld +# Corrupt FIL_PAGE_OFFSET in bug16720368.ibd, +# and update the checksum to the "don't care" value. +# Restart mysqld +# This will succeed after a clean shutdown, due to +# fil_open_single_table_tablespace(check_space_id=FALSE). +SELECT COUNT(*) FROM bug16720368; +COUNT(*) +8 +INSERT INTO bug16720368_1 VALUES(1); +# Kill the server to do an unclean shutdown. +# The corruption should not prevent startup after crash recovery, +# because there is no redo log for the corrupted tablespace. +# The table is unaccessible, because after a crash we will +# validate the tablespace header. +SELECT COUNT(*) FROM bug16720368; +ERROR 42S02: Table 'test.bug16720368' doesn't exist +INSERT INTO bug16720368 VALUES(0,1); +ERROR 42S02: Table 'test.bug16720368' doesn't exist +# Kill the server to do an unclean shutdown. +# The table is readable thanks to innodb-force-recovery. +SELECT COUNT(*) FROM bug16720368; +COUNT(*) +8 +INSERT INTO bug16720368 VALUES(0,1); +ERROR HY000: Operation not allowed when innodb_forced_recovery > 0. +# Shut down the server cleanly to hide the corruption. +# The table is accessible, because after a clean shutdown we will +# NOT validate the tablespace header. +# We can modify the existing pages, but we cannot allocate or free +# any pages, because that would hit the corruption on page 0. +SELECT COUNT(*) FROM bug16720368; +COUNT(*) +8 +INSERT INTO bug16720368 VALUES(0,1); +# Shut down the server to uncorrupt the data. +# Restart the server after uncorrupting the file. +INSERT INTO bug16720368 VALUES(9,1); +SELECT COUNT(*) FROM bug16720368; +COUNT(*) +10 +DROP TABLE bug16720368, bug16720368_1; +# +# Bug#16735660 ASSERT TABLE2 == NULL, ROLLBACK OF RESURRECTED TXNS, +# DICT_TABLE_ADD_TO_CACHE +# +SET GLOBAL innodb_file_per_table=1; +CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; +BEGIN; +INSERT INTO t1 VALUES(42); +CREATE TABLE bug16735660 (a INT PRIMARY KEY) ENGINE=InnoDB; +XA START 'x'; +INSERT INTO bug16735660 VALUES(1),(2),(3); +XA END 'x'; +XA PREPARE 'x'; +# Attempt to start without an *.ibd file. +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +SELECT * FROM bug16735660; +a +1 +2 +3 +XA RECOVER; +formatID gtrid_length bqual_length data +1 1 0 x +XA ROLLBACK 'x'; +SELECT * FROM bug16735660; +a +DROP TABLE bug16735660; diff --git a/mysql-test/suite/innodb/t/alter_kill-master.opt b/mysql-test/suite/innodb/t/alter_kill-master.opt new file mode 100644 index 00000000000..e472160c2b7 --- /dev/null +++ b/mysql-test/suite/innodb/t/alter_kill-master.opt @@ -0,0 +1 @@ +--innodb-doublewrite=false diff --git a/mysql-test/suite/innodb/t/alter_kill.test b/mysql-test/suite/innodb/t/alter_kill.test new file mode 100644 index 00000000000..e85498825d6 --- /dev/null +++ b/mysql-test/suite/innodb/t/alter_kill.test @@ -0,0 +1,174 @@ +# The embedded server does not support restarting in mysql-test-run. +-- source include/not_embedded.inc + +let MYSQLD_DATADIR=`select @@datadir`; +let PAGE_SIZE=`select @@innodb_page_size`; + +-- disable_query_log +call mtr.add_suppression("InnoDB: innodb_force_recovery is on."); +call mtr.add_suppression("InnoDB: Tablespace open failed for.*bug16720368"); +call mtr.add_suppression("InnoDB: Failed to find tablespace.*bug16720368"); +call mtr.add_suppression("InnoDB:.*inconsistent data.*test/bug16720368"); +call mtr.add_suppression("InnoDB: Could not find.*test/bug16720368"); +call mtr.add_suppression("Found 1 prepared XA transactions"); +call mtr.add_suppression("InnoDB: .*test.*bug16720368.*missing"); +call mtr.add_suppression("InnoDB: Operating system error.*in a file operation"); +call mtr.add_suppression("InnoDB: \(The error means\|If you are\)"); +-- enable_query_log + +-- echo # +-- echo # Bug#16720368 INNODB CRASHES ON BROKEN #SQL*.IBD FILE AT STARTUP +-- echo # + +SET GLOBAL innodb_file_per_table=1; + +CREATE TABLE bug16720368_1 (a INT PRIMARY KEY) ENGINE=InnoDB; + +connect (con1,localhost,root); +CREATE TABLE bug16720368 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB; +INSERT INTO bug16720368 (a) VALUES (1),(2),(3),(4),(5),(6),(7),(8); + +connection default; + +-- echo # Cleanly shutdown mysqld +-- source include/shutdown_mysqld.inc + +disconnect con1; + +-- echo # Corrupt FIL_PAGE_OFFSET in bug16720368.ibd, +-- echo # and update the checksum to the "don't care" value. +perl; +my $file = "$ENV{MYSQLD_DATADIR}/test/bug16720368.ibd"; +open(FILE, "+<$file") || die "Unable to open $file"; +print FILE pack("H*","deadbeefc001cafe") || die "Unable to write $file"; +seek(FILE, $ENV{PAGE_SIZE}-8, 0) || die "Unable to seek $file"; +print FILE pack("H*","deadbeef") || die "Unable to write $file"; +close(FILE) || die "Unable to close $file"; +EOF + +-- echo # Restart mysqld +-- source include/start_mysqld.inc + +-- echo # This will succeed after a clean shutdown, due to +-- echo # fil_open_single_table_tablespace(check_space_id=FALSE). +SELECT COUNT(*) FROM bug16720368; + +INSERT INTO bug16720368_1 VALUES(1); + +-- echo # Kill the server to do an unclean shutdown. +-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +-- shutdown_server 0 +-- source include/wait_until_disconnected.inc + +-- echo # The corruption should not prevent startup after crash recovery, +-- echo # because there is no redo log for the corrupted tablespace. +-- source include/start_mysqld.inc + +-- echo # The table is unaccessible, because after a crash we will +-- echo # validate the tablespace header. +--error ER_NO_SUCH_TABLE +SELECT COUNT(*) FROM bug16720368; +--error ER_NO_SUCH_TABLE +INSERT INTO bug16720368 VALUES(0,1); + +-- echo # Kill the server to do an unclean shutdown. +-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +-- shutdown_server 0 +-- source include/wait_until_disconnected.inc + +-- exec echo "restart: --innodb-force-recovery=3" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +-- enable_reconnect +-- source include/wait_until_connected_again.inc +-- disable_reconnect + +-- echo # The table is readable thanks to innodb-force-recovery. +SELECT COUNT(*) FROM bug16720368; +--error ER_INNODB_FORCED_RECOVERY +INSERT INTO bug16720368 VALUES(0,1); + +-- echo # Shut down the server cleanly to hide the corruption. +-- source include/restart_mysqld.inc + +-- echo # The table is accessible, because after a clean shutdown we will +-- echo # NOT validate the tablespace header. +-- echo # We can modify the existing pages, but we cannot allocate or free +-- echo # any pages, because that would hit the corruption on page 0. +SELECT COUNT(*) FROM bug16720368; +INSERT INTO bug16720368 VALUES(0,1); + +-- echo # Shut down the server to uncorrupt the data. +-- source include/shutdown_mysqld.inc + +# Uncorrupt the FIL_PAGE_OFFSET. +perl; +my $file = "$ENV{MYSQLD_DATADIR}/test/bug16720368.ibd"; +open(FILE, "+<$file") || die "Unable to open $file"; +# Uncorrupt FIL_PAGE_OFFSET. +print FILE pack("H*","deadbeef00000000") || die "Unable to write $file"; +close(FILE) || die "Unable to close $file"; +EOF + +-- echo # Restart the server after uncorrupting the file. +-- source include/start_mysqld.inc + +INSERT INTO bug16720368 VALUES(9,1); +SELECT COUNT(*) FROM bug16720368; +# A debug assertion would fail in buf_block_align_instance() +# if we did not uncorrupt the page number first. +DROP TABLE bug16720368, bug16720368_1; + +-- echo # +-- echo # Bug#16735660 ASSERT TABLE2 == NULL, ROLLBACK OF RESURRECTED TXNS, +-- echo # DICT_TABLE_ADD_TO_CACHE +-- echo # + +SET GLOBAL innodb_file_per_table=1; + +CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; +BEGIN; +INSERT INTO t1 VALUES(42); + +-- connect (con1,localhost,root) + +CREATE TABLE bug16735660 (a INT PRIMARY KEY) ENGINE=InnoDB; + +XA START 'x'; +INSERT INTO bug16735660 VALUES(1),(2),(3); +XA END 'x'; +XA PREPARE 'x'; + +-- connect (con2,localhost,root) + +-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +-- shutdown_server 0 +-- source include/wait_until_disconnected.inc +-- disconnect con1 +-- disconnect con2 + +-- connection default + +-- move_file $MYSQLD_DATADIR/test/bug16735660.ibd $MYSQLD_DATADIR/bug16735660.omg + +-- echo # Attempt to start without an *.ibd file. +let SEARCH_FILE= $MYSQLTEST_VARDIR/log/my_restart.err; +-- error 1 +-- exec $MYSQLD_CMD --console > $SEARCH_FILE 2>&1; + +let SEARCH_PATTERN= \[ERROR\] InnoDB: Tablespace [0-9]+ was not found at \..test.bug16735660\.ibd\.; +-- source include/search_pattern_in_file.inc + +-- move_file $MYSQLD_DATADIR/bug16735660.omg $MYSQLD_DATADIR/test/bug16735660.ibd + +-- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +-- enable_reconnect +-- source include/wait_until_connected_again.inc +-- disable_reconnect + +SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +SELECT * FROM bug16735660; + +XA RECOVER; +XA ROLLBACK 'x'; + +SELECT * FROM bug16735660; +DROP TABLE bug16735660; From 91659983eb70be6d4169c21c11f47586bf66826d Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Mon, 14 May 2018 18:46:25 +0530 Subject: [PATCH 25/33] Adjust the tests for MariaDB. New added test case: alter_kill in innodb suite. --- mysql-test/suite/innodb/r/alter_kill.result | 20 +++--- mysql-test/suite/innodb/t/alter_kill.test | 68 ++++++++------------- 2 files changed, 37 insertions(+), 51 deletions(-) diff --git a/mysql-test/suite/innodb/r/alter_kill.result b/mysql-test/suite/innodb/r/alter_kill.result index bdba057acef..9b24fddf9ef 100644 --- a/mysql-test/suite/innodb/r/alter_kill.result +++ b/mysql-test/suite/innodb/r/alter_kill.result @@ -3,9 +3,12 @@ # SET GLOBAL innodb_file_per_table=1; CREATE TABLE bug16720368_1 (a INT PRIMARY KEY) ENGINE=InnoDB; +connect con1,localhost,root; CREATE TABLE bug16720368 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB; INSERT INTO bug16720368 (a) VALUES (1),(2),(3),(4),(5),(6),(7),(8); +connection default; # Cleanly shutdown mysqld +disconnect con1; # Corrupt FIL_PAGE_OFFSET in bug16720368.ibd, # and update the checksum to the "don't care" value. # Restart mysqld @@ -15,22 +18,17 @@ SELECT COUNT(*) FROM bug16720368; COUNT(*) 8 INSERT INTO bug16720368_1 VALUES(1); -# Kill the server to do an unclean shutdown. -# The corruption should not prevent startup after crash recovery, -# because there is no redo log for the corrupted tablespace. # The table is unaccessible, because after a crash we will # validate the tablespace header. SELECT COUNT(*) FROM bug16720368; -ERROR 42S02: Table 'test.bug16720368' doesn't exist +ERROR 42S02: Table 'test.bug16720368' doesn't exist in engine INSERT INTO bug16720368 VALUES(0,1); -ERROR 42S02: Table 'test.bug16720368' doesn't exist -# Kill the server to do an unclean shutdown. +ERROR 42S02: Table 'test.bug16720368' doesn't exist in engine # The table is readable thanks to innodb-force-recovery. SELECT COUNT(*) FROM bug16720368; COUNT(*) 8 INSERT INTO bug16720368 VALUES(0,1); -ERROR HY000: Operation not allowed when innodb_forced_recovery > 0. # Shut down the server cleanly to hide the corruption. # The table is accessible, because after a clean shutdown we will # NOT validate the tablespace header. @@ -38,8 +36,7 @@ ERROR HY000: Operation not allowed when innodb_forced_recovery > 0. # any pages, because that would hit the corruption on page 0. SELECT COUNT(*) FROM bug16720368; COUNT(*) -8 -INSERT INTO bug16720368 VALUES(0,1); +9 # Shut down the server to uncorrupt the data. # Restart the server after uncorrupting the file. INSERT INTO bug16720368 VALUES(9,1); @@ -55,12 +52,17 @@ SET GLOBAL innodb_file_per_table=1; CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; BEGIN; INSERT INTO t1 VALUES(42); +connect con1,localhost,root; CREATE TABLE bug16735660 (a INT PRIMARY KEY) ENGINE=InnoDB; XA START 'x'; INSERT INTO bug16735660 VALUES(1),(2),(3); XA END 'x'; XA PREPARE 'x'; +connection default; +# Kill the server +disconnect con1; # Attempt to start without an *.ibd file. +FOUND 1 /\[ERROR\] InnoDB: Tablespace [0-9]+ was not found at .*test.bug16735660.ibd/ in mysqld.1.err SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; SELECT * FROM bug16735660; a diff --git a/mysql-test/suite/innodb/t/alter_kill.test b/mysql-test/suite/innodb/t/alter_kill.test index e85498825d6..922378d2919 100644 --- a/mysql-test/suite/innodb/t/alter_kill.test +++ b/mysql-test/suite/innodb/t/alter_kill.test @@ -1,19 +1,25 @@ +--source include/have_innodb.inc # The embedded server does not support restarting in mysql-test-run. -- source include/not_embedded.inc +-- source include/no_valgrind_without_big.inc let MYSQLD_DATADIR=`select @@datadir`; let PAGE_SIZE=`select @@innodb_page_size`; -- disable_query_log call mtr.add_suppression("InnoDB: innodb_force_recovery is on."); -call mtr.add_suppression("InnoDB: Tablespace open failed for.*bug16720368"); -call mtr.add_suppression("InnoDB: Failed to find tablespace.*bug16720368"); -call mtr.add_suppression("InnoDB:.*inconsistent data.*test/bug16720368"); -call mtr.add_suppression("InnoDB: Could not find.*test/bug16720368"); +call mtr.add_suppression("InnoDB: Header page contains inconsistent data in .*bug16720368.ibd"); +call mtr.add_suppression("InnoDB: Checksum mismatch in datafile:.*bug16720368"); +call mtr.add_suppression("InnoDB: Ignoring tablespace for.*bug16720368"); call mtr.add_suppression("Found 1 prepared XA transactions"); -call mtr.add_suppression("InnoDB: .*test.*bug16720368.*missing"); call mtr.add_suppression("InnoDB: Operating system error.*in a file operation"); call mtr.add_suppression("InnoDB: \(The error means\|If you are\)"); +call mtr.add_suppression("InnoDB: Ignoring tablespace `test/bug16720368` because it could not be opened"); +call mtr.add_suppression("InnoDB: Tablespace .* was not found at.*bug16735660"); +call mtr.add_suppression("InnoDB: Set innodb_force_recovery=1 to ignore this and to permanently lose all changes to the tablespace."); +call mtr.add_suppression("InnoDB: Plugin initialization aborted*"); +call mtr.add_suppression("Plugin 'InnoDB' init function returned error."); +call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed."); -- enable_query_log -- echo # @@ -55,38 +61,27 @@ SELECT COUNT(*) FROM bug16720368; INSERT INTO bug16720368_1 VALUES(1); --- echo # Kill the server to do an unclean shutdown. --- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --- shutdown_server 0 --- source include/wait_until_disconnected.inc - --- echo # The corruption should not prevent startup after crash recovery, --- echo # because there is no redo log for the corrupted tablespace. --- source include/start_mysqld.inc +--let $shutdown_timeout= 0 +--source include/restart_mysqld.inc -- echo # The table is unaccessible, because after a crash we will -- echo # validate the tablespace header. ---error ER_NO_SUCH_TABLE +--error ER_NO_SUCH_TABLE_IN_ENGINE SELECT COUNT(*) FROM bug16720368; ---error ER_NO_SUCH_TABLE +--error ER_NO_SUCH_TABLE_IN_ENGINE INSERT INTO bug16720368 VALUES(0,1); --- echo # Kill the server to do an unclean shutdown. --- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --- shutdown_server 0 --- source include/wait_until_disconnected.inc - --- exec echo "restart: --innodb-force-recovery=3" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --- enable_reconnect --- source include/wait_until_connected_again.inc --- disable_reconnect +let $restart_parameters = --innodb-force-recovery=3; +--let $shutdown_timeout= 0 +--source include/restart_mysqld.inc -- echo # The table is readable thanks to innodb-force-recovery. SELECT COUNT(*) FROM bug16720368; ---error ER_INNODB_FORCED_RECOVERY INSERT INTO bug16720368 VALUES(0,1); -- echo # Shut down the server cleanly to hide the corruption. +let $shutdown_timeout=; +let $restart_parameters =; -- source include/restart_mysqld.inc -- echo # The table is accessible, because after a clean shutdown we will @@ -94,7 +89,6 @@ INSERT INTO bug16720368 VALUES(0,1); -- echo # We can modify the existing pages, but we cannot allocate or free -- echo # any pages, because that would hit the corruption on page 0. SELECT COUNT(*) FROM bug16720368; -INSERT INTO bug16720368 VALUES(0,1); -- echo # Shut down the server to uncorrupt the data. -- source include/shutdown_mysqld.inc @@ -137,32 +131,22 @@ INSERT INTO bug16735660 VALUES(1),(2),(3); XA END 'x'; XA PREPARE 'x'; --- connect (con2,localhost,root) - --- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --- shutdown_server 0 --- source include/wait_until_disconnected.inc --- disconnect con1 --- disconnect con2 - -- connection default +-- source include/kill_mysqld.inc +-- disconnect con1 -- move_file $MYSQLD_DATADIR/test/bug16735660.ibd $MYSQLD_DATADIR/bug16735660.omg -- echo # Attempt to start without an *.ibd file. -let SEARCH_FILE= $MYSQLTEST_VARDIR/log/my_restart.err; --- error 1 --- exec $MYSQLD_CMD --console > $SEARCH_FILE 2>&1; +let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err; +--source include/start_mysqld.inc -let SEARCH_PATTERN= \[ERROR\] InnoDB: Tablespace [0-9]+ was not found at \..test.bug16735660\.ibd\.; +let SEARCH_PATTERN= \[ERROR\] InnoDB: Tablespace [0-9]+ was not found at .*test.bug16735660.ibd; -- source include/search_pattern_in_file.inc -- move_file $MYSQLD_DATADIR/bug16735660.omg $MYSQLD_DATADIR/test/bug16735660.ibd --- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --- enable_reconnect --- source include/wait_until_connected_again.inc --- disable_reconnect +-- source include/restart_mysqld.inc SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; SELECT * FROM bug16735660; From a1f392a9445b57951db47f12bd5c42251c64ba41 Mon Sep 17 00:00:00 2001 From: Annamalai Gurusami Date: Mon, 20 Apr 2015 14:45:47 +0530 Subject: [PATCH 26/33] Bug #20476395 DICT_LOAD_FOREIGNS() FAILED IN COMMIT_INPLACE_ALTER_TABLE Problem: Suppose there are two tables in the database related through a foreign key constraint - the parent table and the child table. Suppose there is an ALTER TABLE on the child table which gets interrupted in such a way that the child table is not available any more. After crash recovery, an ALTER TABLE on the parent table identifies that its foreign keys cannot be loaded. This results in an error and a debug assert. Solution: Remove the debug assert and change error to a warning. rb#8658 approved by Marko. --- .../suite/innodb/r/alter_foreign_crash.result | 25 +++++++++++++ .../suite/innodb/t/alter_foreign_crash.test | 37 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 mysql-test/suite/innodb/r/alter_foreign_crash.result create mode 100644 mysql-test/suite/innodb/t/alter_foreign_crash.test diff --git a/mysql-test/suite/innodb/r/alter_foreign_crash.result b/mysql-test/suite/innodb/r/alter_foreign_crash.result new file mode 100644 index 00000000000..a92c8246fde --- /dev/null +++ b/mysql-test/suite/innodb/r/alter_foreign_crash.result @@ -0,0 +1,25 @@ +# +# Bug #20476395 DICT_LOAD_FOREIGNS() FAILED IN +# COMMIT_INPLACE_ALTER_TABLE +# +call mtr.add_suppression("InnoDB: Failed to load table"); +create database bug; +use bug; +create table parent(a serial) engine=innodb; +create table child(a serial, foreign key fk (a) references parent(a)); +insert into parent values(1); +insert into child values(1); +SET DEBUG_SYNC='innodb_rename_table_ready SIGNAL s1 WAIT_FOR s2 EXECUTE 2'; +ALTER TABLE child ROW_FORMAT=DYNAMIC, ALGORITHM=COPY; +SET DEBUG_SYNC='now WAIT_FOR s1'; +SET DEBUG_SYNC='now SIGNAL s2 WAIT_FOR s1'; +# Kill and restart +show tables; +Tables_in_bug +parent +alter table parent row_format=dynamic; +Warnings: +Warning 1088 InnoDB: Could not add foreign key constraints. +drop table parent; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails +drop database bug; diff --git a/mysql-test/suite/innodb/t/alter_foreign_crash.test b/mysql-test/suite/innodb/t/alter_foreign_crash.test new file mode 100644 index 00000000000..042fa1dc0ae --- /dev/null +++ b/mysql-test/suite/innodb/t/alter_foreign_crash.test @@ -0,0 +1,37 @@ +--source include/have_innodb.inc +--source include/have_debug_sync.inc +# The embedded server does not support restarting. +--source include/not_embedded.inc + +--echo # +--echo # Bug #20476395 DICT_LOAD_FOREIGNS() FAILED IN +--echo # COMMIT_INPLACE_ALTER_TABLE +--echo # + +call mtr.add_suppression("InnoDB: Failed to load table"); + +create database bug; +use bug; + +create table parent(a serial) engine=innodb; +create table child(a serial, foreign key fk (a) references parent(a)); + +insert into parent values(1); +insert into child values(1); + +connect (con1,localhost,root,,bug); +SET DEBUG_SYNC='innodb_rename_table_ready SIGNAL s1 WAIT_FOR s2 EXECUTE 2'; +--send ALTER TABLE child ROW_FORMAT=DYNAMIC, ALGORITHM=COPY +connection default; +SET DEBUG_SYNC='now WAIT_FOR s1'; +SET DEBUG_SYNC='now SIGNAL s2 WAIT_FOR s1'; +--source include/kill_and_restart_mysqld.inc +disconnect con1; + +show tables; +alter table parent row_format=dynamic; + +--error ER_ROW_IS_REFERENCED +drop table parent; + +drop database bug; From 6e76b402d46a7454a0ca0fb1482c06b9f612ad03 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Mon, 14 May 2018 19:00:52 +0530 Subject: [PATCH 27/33] Adjust the alter_foreign_crash test case for MariaDB --- mysql-test/suite/innodb/r/alter_foreign_crash.result | 7 ++++--- mysql-test/suite/innodb/t/alter_foreign_crash.test | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/mysql-test/suite/innodb/r/alter_foreign_crash.result b/mysql-test/suite/innodb/r/alter_foreign_crash.result index a92c8246fde..66ffb5f5411 100644 --- a/mysql-test/suite/innodb/r/alter_foreign_crash.result +++ b/mysql-test/suite/innodb/r/alter_foreign_crash.result @@ -6,14 +6,16 @@ call mtr.add_suppression("InnoDB: Failed to load table"); create database bug; use bug; create table parent(a serial) engine=innodb; -create table child(a serial, foreign key fk (a) references parent(a)); +create table child(a serial, foreign key fk (a) references parent(a))engine=innodb; insert into parent values(1); insert into child values(1); +connect con1,localhost,root,,bug; SET DEBUG_SYNC='innodb_rename_table_ready SIGNAL s1 WAIT_FOR s2 EXECUTE 2'; ALTER TABLE child ROW_FORMAT=DYNAMIC, ALGORITHM=COPY; +connection default; SET DEBUG_SYNC='now WAIT_FOR s1'; SET DEBUG_SYNC='now SIGNAL s2 WAIT_FOR s1'; -# Kill and restart +disconnect con1; show tables; Tables_in_bug parent @@ -21,5 +23,4 @@ alter table parent row_format=dynamic; Warnings: Warning 1088 InnoDB: Could not add foreign key constraints. drop table parent; -ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails drop database bug; diff --git a/mysql-test/suite/innodb/t/alter_foreign_crash.test b/mysql-test/suite/innodb/t/alter_foreign_crash.test index 042fa1dc0ae..1952a1b30d4 100644 --- a/mysql-test/suite/innodb/t/alter_foreign_crash.test +++ b/mysql-test/suite/innodb/t/alter_foreign_crash.test @@ -14,7 +14,7 @@ create database bug; use bug; create table parent(a serial) engine=innodb; -create table child(a serial, foreign key fk (a) references parent(a)); +create table child(a serial, foreign key fk (a) references parent(a))engine=innodb; insert into parent values(1); insert into child values(1); @@ -25,13 +25,13 @@ SET DEBUG_SYNC='innodb_rename_table_ready SIGNAL s1 WAIT_FOR s2 EXECUTE 2'; connection default; SET DEBUG_SYNC='now WAIT_FOR s1'; SET DEBUG_SYNC='now SIGNAL s2 WAIT_FOR s1'; ---source include/kill_and_restart_mysqld.inc + +--let $shutdown_timeout= 0 +--source include/restart_mysqld.inc disconnect con1; show tables; alter table parent row_format=dynamic; ---error ER_ROW_IS_REFERENCED drop table parent; - drop database bug; From 21e02b2c92e83a0c3fea1e97db85aca0feb9261e Mon Sep 17 00:00:00 2001 From: Annamalai Gurusami Date: Tue, 5 Aug 2014 17:25:57 +0530 Subject: [PATCH 28/33] Bug #19077964 ASSERT PAGE_SIZE.EQUALS_TO SPACE_PAGE_SIZE BTR_COPY_BLOB_PREFIX Problem: The function row_build_index_entry_low() takes a dtuple_t object ('row') and dict_index_t object ('index') as input and returns a new dtuple_t object ('entry') as output. The dtuple_t object 'row' that is given as input might have been constructed from a different dict_index_t object (!= index). So when accessing the externally stored data of the given 'row' we need to make use of the correct index object. Solution: Store the page size information in the associated row_ext_t object. rb#6086 approved by Vasil and Jimmy. --- .../suite/innodb/r/alter_page_size.result | 19 ++++++++++ .../suite/innodb/t/alter_page_size.test | 36 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 mysql-test/suite/innodb/r/alter_page_size.result create mode 100644 mysql-test/suite/innodb/t/alter_page_size.test diff --git a/mysql-test/suite/innodb/r/alter_page_size.result b/mysql-test/suite/innodb/r/alter_page_size.result new file mode 100644 index 00000000000..656369e9538 --- /dev/null +++ b/mysql-test/suite/innodb/r/alter_page_size.result @@ -0,0 +1,19 @@ +# +# Bug #19077964 ASSERT PAGE_SIZE.EQUALS_TO SPACE_PAGE_SIZE +# BTR_COPY_BLOB_PREFIX +# +set global innodb_file_format=Barracuda; +create table t1 (f1 int primary key, f3 linestring not null, +spatial key(f3)) engine=innodb row_format=compressed key_block_size=1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL, + `f3` linestring NOT NULL, + PRIMARY KEY (`f1`), + SPATIAL KEY `f3` (`f3`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1 +insert into t1 values (1, linefromtext(concat('linestring', '( 0 0, 1 1, 2 2, 3 3, 4 4, 5 5, 6 6, 7 7, 8 8, 9 9, 10 10, 11 11, 12 12, 13 13, 14 14, 15 15, 16 16, 17 17, 18 18, 19 19, 20 20, 21 21, 22 22, 23 23, 24 24, 25 25, 26 26, 27 27, 28 28, 29 29, 30 30, 31 31, 32 32, 33 33, 34 34, 35 35, 36 36, 37 37, 38 38, 39 39, 40 40, 41 41, 42 42, 43 43, 44 44, 45 45, 46 46, 47 47, 48 48, 49 49, 50 50, 51 51, 52 52, 53 53, 54 54, 55 55, 56 56, 57 57, 58 58, 59 59, 60 60, 61 61, 62 62, 63 63, 64 64, 65 65, 66 66, 67 67, 68 68, 69 69, 70 70, 71 71, 72 72, 73 73, 74 74, 75 75, 76 76, 77 77, 78 78, 79 79, 9999 9999)')));; +alter table t1 row_format=dynamic, key_block_size=0, algorithm=inplace; +drop table t1; +set global innodb_file_format=default; diff --git a/mysql-test/suite/innodb/t/alter_page_size.test b/mysql-test/suite/innodb/t/alter_page_size.test new file mode 100644 index 00000000000..6f2359ee3a3 --- /dev/null +++ b/mysql-test/suite/innodb/t/alter_page_size.test @@ -0,0 +1,36 @@ + +--source include/have_innodb.inc + +--echo # +--echo # Bug #19077964 ASSERT PAGE_SIZE.EQUALS_TO SPACE_PAGE_SIZE +--echo # BTR_COPY_BLOB_PREFIX +--echo # + +set global innodb_file_format=Barracuda; + +create table t1 (f1 int primary key, f3 linestring not null, + spatial key(f3)) engine=innodb row_format=compressed key_block_size=1; +show create table t1; + +let $points = 80; +let $x = 0; +let $y = 0; +let $linestr = (; + +while ($points) +{ + let $linestr = $linestr $x $y,; + dec $points; + inc $x; + inc $y; +} + +let $linestr = $linestr 9999 9999); + +--eval insert into t1 values (1, linefromtext(concat('linestring', '$linestr'))); + +alter table t1 row_format=dynamic, key_block_size=0, algorithm=inplace; + +drop table t1; + +set global innodb_file_format=default; From be465cfb8c3ca6a3e674cea057b242f4798eac4f Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Mon, 14 May 2018 19:22:26 +0530 Subject: [PATCH 29/33] Move the test case from innodb.alter_page_size to innodb.innodb-online-alter-gis --- .../suite/innodb/r/alter_page_size.result | 19 ---------- .../innodb/r/innodb-online-alter-gis.result | 18 ++++++++++ .../suite/innodb/t/alter_page_size.test | 36 ------------------- .../innodb/t/innodb-online-alter-gis.test | 31 ++++++++++++++++ 4 files changed, 49 insertions(+), 55 deletions(-) delete mode 100644 mysql-test/suite/innodb/r/alter_page_size.result delete mode 100644 mysql-test/suite/innodb/t/alter_page_size.test diff --git a/mysql-test/suite/innodb/r/alter_page_size.result b/mysql-test/suite/innodb/r/alter_page_size.result deleted file mode 100644 index 656369e9538..00000000000 --- a/mysql-test/suite/innodb/r/alter_page_size.result +++ /dev/null @@ -1,19 +0,0 @@ -# -# Bug #19077964 ASSERT PAGE_SIZE.EQUALS_TO SPACE_PAGE_SIZE -# BTR_COPY_BLOB_PREFIX -# -set global innodb_file_format=Barracuda; -create table t1 (f1 int primary key, f3 linestring not null, -spatial key(f3)) engine=innodb row_format=compressed key_block_size=1; -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `f1` int(11) NOT NULL, - `f3` linestring NOT NULL, - PRIMARY KEY (`f1`), - SPATIAL KEY `f3` (`f3`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1 -insert into t1 values (1, linefromtext(concat('linestring', '( 0 0, 1 1, 2 2, 3 3, 4 4, 5 5, 6 6, 7 7, 8 8, 9 9, 10 10, 11 11, 12 12, 13 13, 14 14, 15 15, 16 16, 17 17, 18 18, 19 19, 20 20, 21 21, 22 22, 23 23, 24 24, 25 25, 26 26, 27 27, 28 28, 29 29, 30 30, 31 31, 32 32, 33 33, 34 34, 35 35, 36 36, 37 37, 38 38, 39 39, 40 40, 41 41, 42 42, 43 43, 44 44, 45 45, 46 46, 47 47, 48 48, 49 49, 50 50, 51 51, 52 52, 53 53, 54 54, 55 55, 56 56, 57 57, 58 58, 59 59, 60 60, 61 61, 62 62, 63 63, 64 64, 65 65, 66 66, 67 67, 68 68, 69 69, 70 70, 71 71, 72 72, 73 73, 74 74, 75 75, 76 76, 77 77, 78 78, 79 79, 9999 9999)')));; -alter table t1 row_format=dynamic, key_block_size=0, algorithm=inplace; -drop table t1; -set global innodb_file_format=default; diff --git a/mysql-test/suite/innodb/r/innodb-online-alter-gis.result b/mysql-test/suite/innodb/r/innodb-online-alter-gis.result index 79c0f2386aa..2ba8118feb7 100644 --- a/mysql-test/suite/innodb/r/innodb-online-alter-gis.result +++ b/mysql-test/suite/innodb/r/innodb-online-alter-gis.result @@ -47,3 +47,21 @@ DESCRIBE t1; Field Type Null Key Default Extra a int(11) YES NULL DROP TABLE t1; +# +# Bug #19077964 ASSERT PAGE_SIZE.EQUALS_TO SPACE_PAGE_SIZE +# BTR_COPY_BLOB_PREFIX +# +CREATE TABLE t1(f1 INT PRIMARY KEY, f3 LINESTRING NOT NULL, +SPATIAL KEY(f3))ENGINE=InnoDB ROW_FORMAT=COMPRESSED +KEY_BLOCK_SIZE=1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL, + `f3` linestring NOT NULL, + PRIMARY KEY (`f1`), + SPATIAL KEY `f3` (`f3`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1 +INSERT INTO t1 VALUES (1, ST_linefromtext(concat('linestring', '( 0 0, 1 1, 2 2, 3 3, 4 4, 5 5, 6 6, 7 7, 8 8, 9 9, 10 10, 11 11, 12 12, 13 13, 14 14, 15 15, 16 16, 17 17, 18 18, 19 19, 20 20, 21 21, 22 22, 23 23, 24 24, 25 25, 26 26, 27 27, 28 28, 29 29, 30 30, 31 31, 32 32, 33 33, 34 34, 35 35, 36 36, 37 37, 38 38, 39 39, 40 40, 41 41, 42 42, 43 43, 44 44, 45 45, 46 46, 47 47, 48 48, 49 49, 50 50, 51 51, 52 52, 53 53, 54 54, 55 55, 56 56, 57 57, 58 58, 59 59, 60 60, 61 61, 62 62, 63 63, 64 64, 65 65, 66 66, 67 67, 68 68, 69 69, 70 70, 71 71, 72 72, 73 73, 74 74, 75 75, 76 76, 77 77, 78 78, 79 79, 9999 9999)')));; +ALTER TABLE t1 ROW_FORMAT = DYNAMIC, KEY_BLOCK_SIZE=0, ALGORITHM=INPLACE; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/alter_page_size.test b/mysql-test/suite/innodb/t/alter_page_size.test deleted file mode 100644 index 6f2359ee3a3..00000000000 --- a/mysql-test/suite/innodb/t/alter_page_size.test +++ /dev/null @@ -1,36 +0,0 @@ - ---source include/have_innodb.inc - ---echo # ---echo # Bug #19077964 ASSERT PAGE_SIZE.EQUALS_TO SPACE_PAGE_SIZE ---echo # BTR_COPY_BLOB_PREFIX ---echo # - -set global innodb_file_format=Barracuda; - -create table t1 (f1 int primary key, f3 linestring not null, - spatial key(f3)) engine=innodb row_format=compressed key_block_size=1; -show create table t1; - -let $points = 80; -let $x = 0; -let $y = 0; -let $linestr = (; - -while ($points) -{ - let $linestr = $linestr $x $y,; - dec $points; - inc $x; - inc $y; -} - -let $linestr = $linestr 9999 9999); - ---eval insert into t1 values (1, linefromtext(concat('linestring', '$linestr'))); - -alter table t1 row_format=dynamic, key_block_size=0, algorithm=inplace; - -drop table t1; - -set global innodb_file_format=default; diff --git a/mysql-test/suite/innodb/t/innodb-online-alter-gis.test b/mysql-test/suite/innodb/t/innodb-online-alter-gis.test index 2cb88d398bb..e70659f6d17 100644 --- a/mysql-test/suite/innodb/t/innodb-online-alter-gis.test +++ b/mysql-test/suite/innodb/t/innodb-online-alter-gis.test @@ -29,3 +29,34 @@ CREATE TABLE t1 (a INT) ENGINE=InnoDB; ALTER TABLE t1 ADD COLUMN b LINESTRING DEFAULT POINT(1,1); DESCRIBE t1; DROP TABLE t1; + +--echo # +--echo # Bug #19077964 ASSERT PAGE_SIZE.EQUALS_TO SPACE_PAGE_SIZE +--echo # BTR_COPY_BLOB_PREFIX +--echo # + +CREATE TABLE t1(f1 INT PRIMARY KEY, f3 LINESTRING NOT NULL, + SPATIAL KEY(f3))ENGINE=InnoDB ROW_FORMAT=COMPRESSED + KEY_BLOCK_SIZE=1; +SHOW CREATE TABLE t1; + +let $points = 80; +let $x = 0; +let $y = 0; +let $linestr = (; + +while ($points) +{ + let $linestr = $linestr $x $y,; + dec $points; + inc $x; + inc $y; +} + +let $linestr = $linestr 9999 9999); + +--eval INSERT INTO t1 VALUES (1, ST_linefromtext(concat('linestring', '$linestr'))); + +ALTER TABLE t1 ROW_FORMAT = DYNAMIC, KEY_BLOCK_SIZE=0, ALGORITHM=INPLACE; + +DROP TABLE t1; From 0ba299da02266a5f786c718b03632c0d9433963b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 17 Aug 2015 13:44:52 +0300 Subject: [PATCH 30/33] Bug#21628087 innodb_log_checkpoint_now not fully compatible with WL#7142 In debug builds of MySQL, there is an configuration variable that allows an InnoDB log checkpoint to be initiated: SET GLOBAL innodb_log_checkpoint_now=ON; Setting this variable while a table-rebuilding ALTER TABLE is executing may result in an infinite loop. checkpoint_now_set(): Account for log_sys->append_on_checkpoint->size(). Note that this function contains race conditions, because it is accessing fields of log_sys without holding log_sys->mutex. We think that this is acceptable, because this variable only exists for debugging purposes, in debug builds of MySQL. RB: 9947 Reviewed-by: Sunny Bains --- .../suite/innodb/r/alter_rename_files.result | 17 ++++++++++ .../suite/innodb/t/alter_rename_files.test | 31 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 mysql-test/suite/innodb/r/alter_rename_files.result create mode 100644 mysql-test/suite/innodb/t/alter_rename_files.test diff --git a/mysql-test/suite/innodb/r/alter_rename_files.result b/mysql-test/suite/innodb/r/alter_rename_files.result new file mode 100644 index 00000000000..0c6f29bcdfe --- /dev/null +++ b/mysql-test/suite/innodb/r/alter_rename_files.result @@ -0,0 +1,17 @@ +CREATE TABLE t1 (x INT NOT NULL UNIQUE KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES(5); +SET GLOBAL innodb_log_checkpoint_now=TRUE; +SET DEBUG_SYNC='commit_cache_rebuild SIGNAL ready WAIT_FOR finish'; +ALTER TABLE t1 ADD PRIMARY KEY(x); +SET DEBUG_SYNC='now WAIT_FOR ready'; +SET GLOBAL innodb_log_checkpoint_now=TRUE; +SET DEBUG_SYNC='now SIGNAL finish'; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `x` int(11) NOT NULL, + PRIMARY KEY (`x`), + UNIQUE KEY `x` (`x`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +SET DEBUG_SYNC='RESET'; diff --git a/mysql-test/suite/innodb/t/alter_rename_files.test b/mysql-test/suite/innodb/t/alter_rename_files.test new file mode 100644 index 00000000000..3ed1cb5d9fa --- /dev/null +++ b/mysql-test/suite/innodb/t/alter_rename_files.test @@ -0,0 +1,31 @@ +--source include/have_debug.inc +--source include/have_debug_sync.inc +--source include/have_innodb.inc +--source include/count_sessions.inc + +CREATE TABLE t1 (x INT NOT NULL UNIQUE KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES(5); + +SET GLOBAL innodb_log_checkpoint_now=TRUE; + +# Start an ALTER TABLE and stop it before renaming the files +SET DEBUG_SYNC='commit_cache_rebuild SIGNAL ready WAIT_FOR finish'; + +--send ALTER TABLE t1 ADD PRIMARY KEY(x) + +connect (con1,localhost,root,,); + +SET DEBUG_SYNC='now WAIT_FOR ready'; + +SET GLOBAL innodb_log_checkpoint_now=TRUE; + +SET DEBUG_SYNC='now SIGNAL finish'; + +disconnect con1; +connection default; +reap; +SHOW CREATE TABLE t1; +DROP TABLE t1; +SET DEBUG_SYNC='RESET'; + +--source include/wait_until_count_sessions.inc From 64d6a65ab2190344487925be2773dc8134f653d4 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Mon, 14 May 2018 19:31:38 +0530 Subject: [PATCH 31/33] - Adjusted the test case for MariaDB --- mysql-test/suite/innodb/r/alter_rename_files.result | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mysql-test/suite/innodb/r/alter_rename_files.result b/mysql-test/suite/innodb/r/alter_rename_files.result index 0c6f29bcdfe..7df63a051da 100644 --- a/mysql-test/suite/innodb/r/alter_rename_files.result +++ b/mysql-test/suite/innodb/r/alter_rename_files.result @@ -3,9 +3,12 @@ INSERT INTO t1 VALUES(5); SET GLOBAL innodb_log_checkpoint_now=TRUE; SET DEBUG_SYNC='commit_cache_rebuild SIGNAL ready WAIT_FOR finish'; ALTER TABLE t1 ADD PRIMARY KEY(x); +connect con1,localhost,root,,; SET DEBUG_SYNC='now WAIT_FOR ready'; SET GLOBAL innodb_log_checkpoint_now=TRUE; SET DEBUG_SYNC='now SIGNAL finish'; +disconnect con1; +connection default; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( From a54b581d0330b75ef0eb3f21b78f6570626b784e Mon Sep 17 00:00:00 2001 From: Shaohua Wang Date: Tue, 22 Dec 2015 22:07:13 +0800 Subject: [PATCH 32/33] BUG#22385442 - INNODB: DIFFICULT TO FIND FREE BLOCKS IN THE BUFFER POOL Problem: We keep pinning pages in dict_stats_analyze_index_below_cur(), but doesn't release these pages. When we have a relative small buffer pool size, and big innodb_stats_persistent_sample_pages, there will be no free pages for use. Solution: Use a separate mtr in dict_stats_analyze_index_below_cur(), and commit mtr before return. Reviewed-by: Jimmy Yang RB: 11362 --- .../suite/innodb/r/analyze_table.result | 25 +++++++++++ mysql-test/suite/innodb/t/analyze_table.test | 42 +++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 mysql-test/suite/innodb/r/analyze_table.result create mode 100644 mysql-test/suite/innodb/t/analyze_table.test diff --git a/mysql-test/suite/innodb/r/analyze_table.result b/mysql-test/suite/innodb/r/analyze_table.result new file mode 100644 index 00000000000..a5c25289ad1 --- /dev/null +++ b/mysql-test/suite/innodb/r/analyze_table.result @@ -0,0 +1,25 @@ +CREATE PROCEDURE populate_t1() +BEGIN +DECLARE i int DEFAULT 1; +START TRANSACTION; +WHILE (i <= 1000000) DO +INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); +SET i = i + 1; +END WHILE; +COMMIT; +END| +CREATE TABLE t1( +class INT, +id INT, +title VARCHAR(100) +) ENGINE=InnoDB; +SELECT COUNT(*) FROM t1; +COUNT(*) +1000000 +SET GLOBAL innodb_stats_persistent_sample_pages=2000; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +DROP TABLE t1; +DROP PROCEDURE populate_t1; +SET GLOBAL innodb_stats_persistent_sample_pages=default; diff --git a/mysql-test/suite/innodb/t/analyze_table.test b/mysql-test/suite/innodb/t/analyze_table.test new file mode 100644 index 00000000000..e9db3668f02 --- /dev/null +++ b/mysql-test/suite/innodb/t/analyze_table.test @@ -0,0 +1,42 @@ +# +# BUG#22385442 - INNODB: DIFFICULT TO FIND FREE BLOCKS IN THE BUFFER POOL +# + +--source include/have_innodb.inc +--source include/big_test.inc + +DELIMITER |; +CREATE PROCEDURE populate_t1() +BEGIN + DECLARE i int DEFAULT 1; + + START TRANSACTION; + WHILE (i <= 1000000) DO + INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); + SET i = i + 1; + END WHILE; + COMMIT; +END| +DELIMITER ;| + +CREATE TABLE t1( + class INT, + id INT, + title VARCHAR(100) +) ENGINE=InnoDB; + +-- disable_query_log +CALL populate_t1(); +-- enable_query_log + +SELECT COUNT(*) FROM t1; + +SET GLOBAL innodb_stats_persistent_sample_pages=2000; + +ANALYZE TABLE t1; + +DROP TABLE t1; + +DROP PROCEDURE populate_t1; + +SET GLOBAL innodb_stats_persistent_sample_pages=default; From a4e7800701d0764fe4cbb85b81d7c7cb54677334 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 16 May 2018 16:35:33 +0300 Subject: [PATCH 33/33] MDEV-13779 InnoDB fails to shut down purge workers, causing hang srv_purge_coordinator_thread(): Wait for all purge worker threads to actually exit. An analysis of a core dump of a hung 10.3 server revealed that one srv_worker_thread did not exit, even though the purge coordinator had exited. This caused kill_server_thread and mysqld_main to wait indefinitely. The main InnoDB shutdown was never called, because unireg_end() was never called. --- storage/innobase/srv/srv0srv.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index 5f93ff7cd7c..802271bb96f 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -2876,8 +2876,18 @@ DECLARE_THREAD(srv_purge_coordinator_thread)( #endif /* UNIV_DEBUG_THREAD_CREATION */ /* Ensure that all the worker threads quit. */ - if (srv_n_purge_threads > 1) { - srv_release_threads(SRV_WORKER, srv_n_purge_threads - 1); + if (ulint n_workers = srv_n_purge_threads - 1) { + const srv_slot_t* slot; + const srv_slot_t* const end = &srv_sys.sys_threads[ + srv_sys.n_sys_threads]; + + do { + srv_release_threads(SRV_WORKER, n_workers); + srv_sys_mutex_enter(); + for (slot = &srv_sys.sys_threads[2]; + !slot++->in_use && slot < end; ); + srv_sys_mutex_exit(); + } while (slot < end); } innobase_destroy_background_thd(thd);