Commit 505da21e authored by Alexander Barkov's avatar Alexander Barkov

MDEV-27214 Import with disabled keys corrupts meta-data like rows, indexes, ...

This bug was previously fixed in 10.6.11 by:
   MDEV-28327 InnoDB persistent statistics fail to update after bulk insert

Adding MTR tests only.

Also, fixing the old test for MDEV-28327 to make "mtr" reliably pass
with/without --mysqld=--innodb-stats-persistent=0, and with different page sizes,
as suggested by Marko.
parent f4adf354
......@@ -186,11 +186,30 @@ DROP TABLE t;
# MDEV-28327 InnoDB persistent statistics fail to update
# after bulk insert
#
CREATE TABLE t1 (a INT PRIMARY KEY)ENGINE=InnoDB;
CREATE TABLE t1 (a INT PRIMARY KEY)ENGINE=InnoDB
STATS_PERSISTENT=1 STATS_AUTO_RECALC=1;
INSERT INTO t1 SELECT * FROM seq_1_to_4096;
# Wait till statistics update after bulk insert operation
SELECT n_rows FROM mysql.innodb_table_stats WHERE TABLE_NAME="t1";
n_rows
4096
SELECT n_rows>=4096 FROM mysql.innodb_table_stats WHERE TABLE_NAME="t1";
n_rows>=4096
1
DROP TABLE t1;
#
# MDEV-27214 Import with disabled keys corrupts meta-data like rows, indexes, ...
#
SET UNIQUE_CHECKS=0;
SET FOREIGN_KEY_CHECKS=0;
CREATE TABLE `t1` (
`id` int(11) NOT NULL,
`a` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
STATS_PERSISTENT=1 STATS_AUTO_RECALC=1;
INSERT INTO `t1` VALUES (1,2),(2,3),(3,4);
# Wait till statistics update after bulk insert operation
SELECT TABLE_ROWS, AVG_ROW_LENGTH>0 FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test';
TABLE_ROWS AVG_ROW_LENGTH>0
3 1
DROP TABLE t1;
# End of 10.6 tests
#
# Start of 10.6 tests
#
#
# MDEV-27214 Import with disabled keys corrupts meta-data like rows, indexes, ...
#
CREATE DATABASE db1;
CREATE TABLE db1.t1 (id int, a int,PRIMARY KEY (id)) ENGINE=InnoDB
STATS_PERSISTENT=1 STATS_AUTO_RECALC=1;
INSERT INTO db1.t1 VALUES (1,2),(2,3),(3,4);
DROP DATABASE IF EXISTS db1;
CREATE DATABASE db1;
# Wait till statistics update after bulk insert operation
SELECT TABLE_ROWS, AVG_ROW_LENGTH>0 FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='db1';
TABLE_ROWS AVG_ROW_LENGTH>0
3 1
OPTIMIZE TABLE db1.t1;
Table Op Msg_type Msg_text
db1.t1 optimize note Table does not support optimize, doing recreate + analyze instead
db1.t1 optimize status OK
# Wait till statistics update after bulk insert operation
SELECT TABLE_ROWS, AVG_ROW_LENGTH>0 FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='db1';
TABLE_ROWS AVG_ROW_LENGTH>0
3 1
DROP DATABASE db1;
#
# End of 10.6 tests
#
--source include/have_innodb.inc
--source include/innodb_page_size.inc
--source include/have_sequence.inc
--source include/maybe_debug.inc
--source include/have_partition.inc
......@@ -198,13 +199,37 @@ DROP TABLE t;
--echo # MDEV-28327 InnoDB persistent statistics fail to update
--echo # after bulk insert
--echo #
CREATE TABLE t1 (a INT PRIMARY KEY)ENGINE=InnoDB;
CREATE TABLE t1 (a INT PRIMARY KEY)ENGINE=InnoDB
STATS_PERSISTENT=1 STATS_AUTO_RECALC=1;
INSERT INTO t1 SELECT * FROM seq_1_to_4096;
--echo # Wait till statistics update after bulk insert operation
let $wait_condition= select n_rows > 100 from mysql.innodb_table_stats
where table_name="t1";
source include/wait_condition.inc;
SELECT n_rows FROM mysql.innodb_table_stats WHERE TABLE_NAME="t1";
SELECT n_rows>=4096 FROM mysql.innodb_table_stats WHERE TABLE_NAME="t1";
DROP TABLE t1;
--echo #
--echo # MDEV-27214 Import with disabled keys corrupts meta-data like rows, indexes, ...
--echo #
SET UNIQUE_CHECKS=0;
SET FOREIGN_KEY_CHECKS=0;
CREATE TABLE `t1` (
`id` int(11) NOT NULL,
`a` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
STATS_PERSISTENT=1 STATS_AUTO_RECALC=1;
INSERT INTO `t1` VALUES (1,2),(2,3),(3,4);
--echo # Wait till statistics update after bulk insert operation
let $wait_condition= select n_rows > 0 from mysql.innodb_table_stats
where database_name='test' and table_name='t1';
source include/wait_condition.inc;
SELECT TABLE_ROWS, AVG_ROW_LENGTH>0 FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test';
DROP TABLE t1;
--echo # End of 10.6 tests
--source include/not_embedded.inc
--source include/have_innodb.inc
--source include/innodb_page_size.inc
--source include/maybe_debug.inc
--echo #
--echo # Start of 10.6 tests
--echo #
--echo #
--echo # MDEV-27214 Import with disabled keys corrupts meta-data like rows, indexes, ...
--echo #
CREATE DATABASE db1;
CREATE TABLE db1.t1 (id int, a int,PRIMARY KEY (id)) ENGINE=InnoDB
STATS_PERSISTENT=1 STATS_AUTO_RECALC=1;
INSERT INTO db1.t1 VALUES (1,2),(2,3),(3,4);
--let $file = $MYSQLTEST_VARDIR/tmp/dump.sql
--exec $MYSQL_DUMP db1 t1 >$file
DROP DATABASE IF EXISTS db1;
CREATE DATABASE db1;
--exec $MYSQL db1 < $file
--remove_file $file
--echo # Wait till statistics update after bulk insert operation
let $wait_condition= select n_rows > 0 from mysql.innodb_table_stats
where database_name='db1' and table_name='t1';
source include/wait_condition.inc;
SELECT TABLE_ROWS, AVG_ROW_LENGTH>0 FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='db1';
OPTIMIZE TABLE db1.t1;
--echo # Wait till statistics update after bulk insert operation
let $wait_condition= select n_rows > 0 from mysql.innodb_table_stats
where database_name='db1' and table_name='t1';
source include/wait_condition.inc;
SELECT TABLE_ROWS, AVG_ROW_LENGTH>0 FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='db1';
DROP DATABASE db1;
--echo #
--echo # End of 10.6 tests
--echo #
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment