Commit cb0ce5c2 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-6076: Optimize the test.

Remove unnecessary restarts by testing multiple tables across a restart.
This change almost halves the execution time.
Some further restarts could be removed with additional effort.
parent 8777458a
......@@ -41,21 +41,17 @@ eval SELECT MAX(a) AS `Expect 124` FROM $table;
eval OPTIMIZE TABLE $table;
eval SHOW CREATE TABLE $table;
--source include/restart_mysqld.inc
--echo # We expect the counter to still be 125
eval SHOW CREATE TABLE $table;
eval DELETE FROM $table WHERE a >= 123;
eval CREATE UNIQUE INDEX idx_aa ON $table(a);
eval CREATE TABLE i$table(a INT AUTO_INCREMENT, INDEX(a)) AUTO_INCREMENT=125 ENGINE=InnoDB;
eval CREATE UNIQUE INDEX idx_aa ON i$table(a);
--source include/restart_mysqld.inc
eval INSERT INTO $table VALUES(0), (0);
eval INSERT INTO i$table VALUES(0), (0);
eval SELECT MAX(a) AS `Expect 126` FROM $table;
eval SELECT MAX(a) AS `Expect 126` FROM i$table;
eval DROP TABLE $table;
eval DROP TABLE $table, i$table;
--source include/have_innodb.inc
# Restarting is not supported when testing the embedded server.
--source include/not_embedded.inc
--echo #
......@@ -84,45 +85,15 @@ INSERT INTO t11 VALUES(0), (0), (0), (0), (-1), (-10), (0),
(20), (30), (31);
SELECT * FROM t11;
# Since autoinc counter is persisted by redo logs, we don't want to
# lose them on kill and restart, so to make the result after restart stable.
set global innodb_flush_log_at_trx_commit=1;
CREATE TABLE t12(a DOUBLE AUTO_INCREMENT KEY) ENGINE = InnoDB;
INSERT INTO t12 VALUES(0), (0), (0), (0), (-1), (-10), (0),
(20), (30), (31);
SELECT * FROM t12;
CREATE TABLE t13(a INT AUTO_INCREMENT PRIMARY KEY) ENGINE = InnoDB,
AUTO_INCREMENT = 1234;
--echo # Scenario 1: Normal restart, to test if the counters are persisted
--source include/restart_mysqld.inc
--echo # We expect these results should be equal to above SELECTs
SELECT * FROM t1;
SELECT * FROM t2;
SELECT * FROM t3;
SELECT * FROM t4;
SELECT * FROM t5;
SELECT * FROM t6;
SELECT * FROM t7;
SELECT * FROM t8;
SELECT * FROM t9;
SELECT * FROM t10;
SELECT * FROM t11;
SELECT * FROM t12;
SELECT * FROM t13;
SHOW CREATE TABLE t13;
INSERT INTO t13 VALUES(0);
SELECT a AS `Expect 1234` FROM t13;
--echo # Scenario 2: Delete some values, to test the counters should not be the
--echo # one which is the largest in current table
set global innodb_flush_log_at_trx_commit=1;
DELETE FROM t1 WHERE a > 30;
SELECT MAX(a) AS `Expect 30` FROM t1;
DELETE FROM t3 WHERE a > 2000;
......@@ -134,8 +105,16 @@ SELECT MAX(a) AS `Expect 100000000` FROM t7;
DELETE FROM t9 WHERE a > 100000000000;
SELECT MAX(a) AS `Expect 100000000000` FROM t9;
CREATE TABLE t13(a INT AUTO_INCREMENT PRIMARY KEY) ENGINE = InnoDB,
AUTO_INCREMENT = 1234;
--source include/restart_mysqld.inc
SHOW CREATE TABLE t13;
INSERT INTO t13 VALUES(0);
SELECT a AS `Expect 1234` FROM t13;
DROP TABLE t13;
INSERT INTO t1 VALUES(0), (0);
SELECT MAX(a) AS `Expect 33` FROM t1;
INSERT INTO t3 VALUES(0), (0);
......@@ -222,8 +201,6 @@ DELETE FROM t7 WHERE a > 100000105;
INSERT INTO t7 VALUES(0);
SELECT MAX(a) AS `Expect 100000109` FROM t7;
set global innodb_flush_log_at_trx_commit=1;
INSERT INTO t9 VALUES(100), (200);
# Updating to bigger value will update the auto-increment counter
UPDATE t9 SET a = 100000000105 WHERE a = 5;
......@@ -268,6 +245,7 @@ DELETE FROM t5 WHERE a = 1100200;
INSERT INTO t7 VALUES(100000200);
DELETE FROM t7 WHERE a = 100000200;
--echo # Ensure that all changes before the server is killed are persisted.
set global innodb_flush_log_at_trx_commit=1;
INSERT INTO t9 VALUES(100000000200);
......@@ -313,6 +291,7 @@ SELECT * FROM t7;
INSERT INTO t9 VALUES(0), (0);
SELECT * FROM t9;
--echo # Ensure that all changes before the server is killed are persisted.
set global innodb_flush_log_at_trx_commit=1;
TRUNCATE TABLE t1;
......@@ -321,6 +300,12 @@ TRUNCATE TABLE t5;
TRUNCATE TABLE t7;
TRUNCATE TABLE t9;
--echo # Scenario 7: Test explicit rename table won't change the counter
RENAME TABLE t9 to t19;
INSERT INTO t19 VALUES(0), (0);
SELECT * FROM t19;
--source include/kill_and_restart_mysqld.inc
INSERT INTO t1 VALUES(0), (0);
......@@ -335,20 +320,10 @@ SELECT * FROM t5;
INSERT INTO t7 VALUES(0), (0);
SELECT * FROM t7;
INSERT INTO t9 VALUES(0), (0);
SELECT * FROM t9;
--echo # Scenario 7: Test explicit rename table won't change the counter
set global innodb_flush_log_at_trx_commit=1;
RENAME TABLE t9 to t19;
INSERT INTO t19 VALUES(0), (0);
SELECT * FROM t19;
DELETE FROM t19 WHERE a = 4;
--source include/kill_and_restart_mysqld.inc
RENAME TABLE t19 to t9;
INSERT INTO t9 VALUES(0), (0);
SELECT * FROM t9;
......@@ -413,14 +388,12 @@ ALGORITHM=INPLACE;
INSERT INTO t3 VALUES(0);
SELECT MAX(a) AS `Expect 120` FROM t3;
INSERT INTO mdev6076a SET b=0;
INSERT INTO mdev6076a SET b=NULL;
SELECT * FROM mdev6076a;
INSERT INTO mdev6076b SET b=0;
INSERT INTO mdev6076b SET b=NULL;
SELECT * FROM mdev6076b;
DROP TABLE mdev6076a, mdev6076b;
set global innodb_flush_log_at_trx_commit=1;
INSERT INTO t3 VALUES(0), (0), (200), (210);
--echo # Test the different algorithms in ALTER TABLE
......@@ -445,6 +418,7 @@ SELECT * FROM t30 ORDER BY b;
ALTER TABLE t30 MODIFY b MEDIUMINT;
SELECT * FROM t30 ORDER BY b;
--echo # Ensure that all changes before the server is killed are persisted.
set global innodb_flush_log_at_trx_commit=1;
CREATE TABLE t31 (a INT) ENGINE = InnoDB;
......@@ -455,25 +429,6 @@ INSERT INTO t31 VALUES(3, 0), (4, NULL), (5, NULL);
INSERT INTO t31 VALUES(6, 0);
SELECT * FROM t31;
--source include/kill_and_restart_mysqld.inc
--echo # This will not insert 0
INSERT INTO t31(a) VALUES(6), (0);
SELECT * FROM t31;
DROP TABLE t31;
set SQL_MODE = NO_AUTO_VALUE_ON_ZERO;
DELETE FROM t30 WHERE a = 0;
UPDATE t30 set a = 0 where b = 5;
SELECT * FROM t30 ORDER BY b;
DELETE FROM t30 WHERE a = 0;
UPDATE t30 SET a = NULL WHERE b = 6;
UPDATE t30 SET a = 300 WHERE b = 7;
SELECT * FROM t30 ORDER BY b;
SET SQL_MODE = 0;
--echo # Scenario 10: Rollback would not rollback the counter
......@@ -482,6 +437,7 @@ a BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
INSERT INTO t32 VALUES(0), (0);
--echo # Ensure that all changes before the server is killed are persisted.
set global innodb_flush_log_at_trx_commit=1;
START TRANSACTION;
......@@ -490,12 +446,6 @@ SELECT MAX(a) AS `Expect 4` FROM t32;
DELETE FROM t32 WHERE a >= 2;
ROLLBACK;
--source include/kill_and_restart_mysqld.inc
SELECT MAX(a) AS `Expect 2` FROM t32;
INSERT INTO t32 VALUES(0), (0);
SELECT MAX(a) AS `Expect 6` FROM t32;
--echo # Scenario 11: Test duplicate primary key/secondary key will not stop
--echo # increasing the counter
......@@ -527,7 +477,30 @@ COMMIT;
--source include/kill_and_restart_mysqld.inc
--echo # This will not insert 0
INSERT INTO t31(a) VALUES(6), (0);
SELECT * FROM t31;
DROP TABLE t31;
set SQL_MODE = NO_AUTO_VALUE_ON_ZERO;
DELETE FROM t30 WHERE a = 0;
UPDATE t30 set a = 0 where b = 5;
SELECT * FROM t30 ORDER BY b;
DELETE FROM t30 WHERE a = 0;
UPDATE t30 SET a = NULL WHERE b = 6;
UPDATE t30 SET a = 300 WHERE b = 7;
SELECT * FROM t30 ORDER BY b;
SET SQL_MODE = 0;
SELECT MAX(a) AS `Expect 2` FROM t32;
INSERT INTO t32 VALUES(0), (0);
SELECT MAX(a) AS `Expect 6` FROM t32;
INSERT INTO t33 VALUES(3, NULL);
SELECT MAX(b) AS `Expect 4` FROM t33;
DROP TABLE t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t30, t32, t33;
DROP TABLE t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t30, t32, t33;
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