Skip to content

Commit

Permalink
MDEV-28866: mariadb-upgrade to 10.8 mysql.column_stats hist_type + hi…
Browse files Browse the repository at this point in the history
…stogram errors

The incorrect type of mysql.column_stats caused the server during the
upgrade of every other table to complain:

[ERROR] Incorrect definition of table mysql.column_stats: expected column 'hist_type' at position 9
and expected column 'histogram' at position 10 to have type longblob.

To prevent these verbose server errors, we upgrade the
mysql.column_stats table first.

Consequently limit "Incorrect definition of table mysql.*" to the appropriate
set of limited test cases.

The rpl_gtid_errorhandling.result changes the GTID number by one
because of the added early suppression (adding a table row).

Reviewer: Vicențiu Ciorbaru

Fixes MariaDB/mariadb-docker#438
  • Loading branch information
grooverdan committed Jul 11, 2022
1 parent 155019b commit 3fbcd68
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 17 deletions.
1 change: 0 additions & 1 deletion mysql-test/include/mtr_warnings.sql
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ INSERT INTO global_suppressions VALUES
*/

("Got error [0-9]* when reading table"),
("Incorrect definition of table"),
("Incorrect information in file"),
("InnoDB: Warning: we did not need to do crash recovery"),
/*("Invalid \\(old\\?\\) table or database name"),*/
Expand Down
1 change: 1 addition & 0 deletions mysql-test/main/events_1.result
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
set sql_mode="";
call mtr.add_suppression("Column count of mysql.event is wrong. Expected .*, found .*\. The table is probably corrupted");
call mtr.add_suppression("Incorrect definition of table mysql.event:.*");
drop database if exists events_test;
drop database if exists db_x;
drop database if exists mysqltest_db2;
Expand Down
1 change: 1 addition & 0 deletions mysql-test/main/events_1.test
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ set sql_mode="";
--source include/default_charset.inc

call mtr.add_suppression("Column count of mysql.event is wrong. Expected .*, found .*\. The table is probably corrupted");
call mtr.add_suppression("Incorrect definition of table mysql.event:.*");

--disable_warnings
drop database if exists events_test;
Expand Down
1 change: 1 addition & 0 deletions mysql-test/main/events_restart.result
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ insert into event_like select * from mysql.event;
alter table mysql.event
change column body body longtext character set utf8 collate utf8_bin;
"Now we restart the server"
call mtr.add_suppression("Incorrect definition of table mysql.event:.*");
# restart
use events_test;
select @@event_scheduler;
Expand Down
1 change: 1 addition & 0 deletions mysql-test/main/events_restart.test
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ alter table mysql.event
change column body body longtext character set utf8 collate utf8_bin;
--echo "Now we restart the server"

call mtr.add_suppression("Incorrect definition of table mysql.event:.*");
--source include/restart_mysqld.inc

use events_test;
Expand Down
1 change: 1 addition & 0 deletions mysql-test/main/mysql_upgrade.result
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
set sql_mode="";
call mtr.add_suppression("Incorrect definition of table mysql.column_stats:.*");
Run mysql_upgrade once
Phase 1/7: Checking and upgrading mysql database
Processing databases
Expand Down
1 change: 1 addition & 0 deletions mysql-test/main/mysql_upgrade.test
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

set sql_mode="";

call mtr.add_suppression("Incorrect definition of table mysql.column_stats:.*");
#
# Basic test that we can run mysql_upgrde and that it finds the
# expected binaries it uses.
Expand Down
4 changes: 4 additions & 0 deletions mysql-test/main/statistics_upgrade.result
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,7 @@ db_name table_name hist_type_equal histogram_equal
test t1 1 1
test t2 1 1
drop table t1,t2,t4;
#
# MDEV-28866 mariadb-upgrade to 10.8 mysql.column_stats hist_type + histogram errors
#
FOUND 2 /Incorrect definition of table mysql.column_stats:/ in mysqld.1.err
10 changes: 10 additions & 0 deletions mysql-test/main/statistics_upgrade.test
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,13 @@ from
A.column_name=B.column_name;

drop table t1,t2,t4;

--echo #
--echo # MDEV-28866 mariadb-upgrade to 10.8 mysql.column_stats hist_type + histogram errors
--echo #
# There should only be two count here corresponding the test creation of mysql.column_stats, and
# none generated by the $MYSQL_UPGRADE run.
--let $error_log= $MYSQLTEST_VARDIR/log/mysqld.1.err
--let SEARCH_FILE= $error_log
--let SEARCH_PATTERN= Incorrect definition of table mysql.column_stats:
--source include/search_pattern_in_file.inc
9 changes: 5 additions & 4 deletions mysql-test/suite/rpl/r/rpl_gtid_errorhandling.result
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ include/master-slave.inc
*** Test that we check against incorrect table definition for mysql.gtid_slave_pos ***
connection master;
CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB;
call mtr.add_suppression("Incorrect definition of table mysql.gtid_slave_pos:.*");
connection slave;
connection slave;
include/stop_slave.inc
Expand Down Expand Up @@ -83,16 +84,16 @@ ERROR 25000: You are not allowed to execute this command in a transaction
ROLLBACK;
SET GLOBAL gtid_strict_mode= 1;
SET GLOBAL gtid_slave_pos = "0-1-1";
ERROR HY000: Specified GTID 0-1-1 conflicts with the binary log which contains a more recent GTID 0-2-11. If MASTER_GTID_POS=CURRENT_POS is used, the binlog position will override the new value of @@gtid_slave_pos
ERROR HY000: Specified GTID 0-1-1 conflicts with the binary log which contains a more recent GTID 0-2-12. If MASTER_GTID_POS=CURRENT_POS is used, the binlog position will override the new value of @@gtid_slave_pos
SET GLOBAL gtid_slave_pos = "";
ERROR HY000: Specified value for @@gtid_slave_pos contains no value for replication domain 0. This conflicts with the binary log which contains GTID 0-2-11. If MASTER_GTID_POS=CURRENT_POS is used, the binlog position will override the new value of @@gtid_slave_pos
ERROR HY000: Specified value for @@gtid_slave_pos contains no value for replication domain 0. This conflicts with the binary log which contains GTID 0-2-12. If MASTER_GTID_POS=CURRENT_POS is used, the binlog position will override the new value of @@gtid_slave_pos
SET GLOBAL gtid_strict_mode= 0;
SET GLOBAL gtid_slave_pos = "0-1-1";
Warnings:
Warning 1947 Specified GTID 0-1-1 conflicts with the binary log which contains a more recent GTID 0-2-11. If MASTER_GTID_POS=CURRENT_POS is used, the binlog position will override the new value of @@gtid_slave_pos
Warning 1947 Specified GTID 0-1-1 conflicts with the binary log which contains a more recent GTID 0-2-12. If MASTER_GTID_POS=CURRENT_POS is used, the binlog position will override the new value of @@gtid_slave_pos
SET GLOBAL gtid_slave_pos = "";
Warnings:
Warning 1948 Specified value for @@gtid_slave_pos contains no value for replication domain 0. This conflicts with the binary log which contains GTID 0-2-11. If MASTER_GTID_POS=CURRENT_POS is used, the binlog position will override the new value of @@gtid_slave_pos
Warning 1948 Specified value for @@gtid_slave_pos contains no value for replication domain 0. This conflicts with the binary log which contains GTID 0-2-12. If MASTER_GTID_POS=CURRENT_POS is used, the binlog position will override the new value of @@gtid_slave_pos
RESET MASTER;
SET GLOBAL gtid_slave_pos = "0-1-1";
START SLAVE;
Expand Down
1 change: 1 addition & 0 deletions mysql-test/suite/rpl/t/rpl_gtid_errorhandling.test
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
--echo *** Test that we check against incorrect table definition for mysql.gtid_slave_pos ***
--connection master
CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB;
call mtr.add_suppression("Incorrect definition of table mysql.gtid_slave_pos:.*");
--sync_slave_with_master

--connection slave
Expand Down
24 changes: 12 additions & 12 deletions scripts/mysql_system_tables_fix.sql
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ set default_storage_engine=Aria;
set enforce_storage_engine=NULL;
set alter_algorithm=DEFAULT;


--
-- Upgrade mysql.column_stats table early because its quite noisy otherwise
--

ALTER TABLE column_stats
modify min_value varbinary(255) DEFAULT NULL,
modify max_value varbinary(255) DEFAULT NULL,
modify hist_type enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB'),
modify histogram longblob,
ENGINE=Aria transactional=0;

set @have_innodb= (select count(engine) from information_schema.engines where engine='INNODB' and support != 'NO');

# MDEV-21873: 10.2 to 10.3 upgrade doesn't remove semi-sync reference from
Expand Down Expand Up @@ -66,7 +78,6 @@ ALTER TABLE help_category ENGINE=Aria transactional=0;
ALTER TABLE help_relation ENGINE=Aria transactional=0;
ALTER TABLE help_keyword ENGINE=Aria transactional=0;
ALTER TABLE table_stats ENGINE=Aria transactional=0;
ALTER TABLE column_stats ENGINE=Aria transactional=0;
ALTER TABLE index_stats ENGINE=Aria transactional=0;

ALTER TABLE user add File_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
Expand Down Expand Up @@ -780,9 +791,6 @@ flush privileges;
ALTER TABLE help_category MODIFY url TEXT NOT NULL;
ALTER TABLE help_topic MODIFY url TEXT NOT NULL;

# MDEV-7383 - varbinary on mix/max of column_stats
alter table column_stats modify min_value varbinary(255) DEFAULT NULL, modify max_value varbinary(255) DEFAULT NULL;

DELIMITER //
IF 'BASE TABLE' = (select table_type from information_schema.tables where table_schema=database() and table_name='user') THEN
CREATE TABLE IF NOT EXISTS global_priv (Host char(255) binary DEFAULT '', User char(128) binary DEFAULT '', Priv JSON NOT NULL DEFAULT '{}' CHECK(JSON_VALID(Priv)), PRIMARY KEY Host (Host,User)) engine=Aria transactional=1 CHARACTER SET utf8 COLLATE utf8_bin comment='Users and global privileges'
Expand Down Expand Up @@ -842,11 +850,3 @@ IF 1 = (SELECT count(*) FROM information_schema.VIEWS WHERE TABLE_CATALOG = 'def
END IF//

DELIMITER ;

--
-- Upgrade mysql.column_stats table
--

ALTER TABLE column_stats
modify hist_type enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB'),
modify histogram longblob;

0 comments on commit 3fbcd68

Please sign in to comment.