mariadb/mysql-test/suite/innodb/include/innodb_simulate_comp_failures.inc
Jan Lindström 2e814d4702 Merge InnoDB 5.7 from mysql-5.7.9.
Contains also

MDEV-10547: Test multi_update_innodb fails with InnoDB 5.7

	The failure happened because 5.7 has changed the signature of
	the bool handler::primary_key_is_clustered() const
	virtual function ("const" was added). InnoDB was using the old
	signature which caused the function not to be used.

MDEV-10550: Parallel replication lock waits/deadlock handling does not work with InnoDB 5.7

	Fixed mutexing problem on lock_trx_handle_wait. Note that
	rpl_parallel and rpl_optimistic_parallel tests still
	fail.

MDEV-10156 : Group commit tests fail on 10.2 InnoDB (branch bb-10.2-jan)
  Reason: incorrect merge

MDEV-10550: Parallel replication can't sync with master in InnoDB 5.7 (branch bb-10.2-jan)
  Reason: incorrect merge
2016-09-02 13:22:28 +03:00

164 lines
3.7 KiB
PHP

--echo #
--echo # Testing robustness against random compression failures
--echo #
--source include/not_embedded.inc
--source include/have_innodb.inc
--disable_query_log
# record the file format in order to restore in the end.
--let $file_format_save = `SELECT @@innodb_file_format`
--let $file_format_max_save = `SELECT @@innodb_file_format_max`
--let $simulate_comp_failures_save = `SELECT @@innodb_simulate_comp_failures`
--disable_warnings
DROP TABLE IF EXISTS t1;
SET GLOBAL INNODB_FILE_FORMAT='Barracuda';
--enable_warnings
# since this test generates lot of errors in log, suppress checking errors
call mtr.add_suppression(".*");
--enable_query_log
# create the table with compressed pages of size 8K.
CREATE TABLE t1(id INT AUTO_INCREMENT PRIMARY KEY, msg VARCHAR(255), KEY msg_i(msg)) ENGINE=INNODB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
SHOW CREATE TABLE t1;
# percentage of compressions that will be forced to fail
SET GLOBAL innodb_simulate_comp_failures = 25;
--disable_query_log
--disable_result_log
let $num_inserts_ind = $num_inserts;
let $commit_iterations=50;
while ($num_inserts_ind)
{
let $repeat = `select floor(rand() * 10)`;
eval INSERT INTO t1(id, msg)
VALUES ($num_inserts_ind, REPEAT('abcdefghijklmnopqrstuvwxyz', $repeat));
dec $num_inserts_ind;
}
--enable_query_log
--enable_result_log
COMMIT;
SELECT COUNT(id) FROM t1;
--disable_query_log
--disable_result_log
# do random ops, making sure that some pages will get fragmented and reorganized.
let $num_ops_ind = $num_ops;
let $commit_count= $commit_iterations;
BEGIN;
while($num_ops_ind)
{
let $idx = `select floor(rand()*$num_inserts)`;
let $insert_or_update = `select floor(rand()*3)`;
let $repeat = `select floor(rand() * 9) + 1`;
let $msg = query_get_value(`select repeat('abcdefghijklmnopqrstuvwxyz', $repeat) as x`, x, 1);
let $single_or_multi = `select floor(rand()*10)`;
if ($insert_or_update)
{
let $cnt = query_get_value(SELECT COUNT(*) cnt FROM t1 WHERE id=$idx, cnt, 1);
if ($cnt)
{
let $update = `select floor(rand()*2)`;
if ($update)
{
if ($single_or_multi)
{
eval UPDATE t1 SET msg=\"$msg\" WHERE id=$idx;
}
if (!$single_or_multi)
{
eval UPDATE t1 SET msg=\"$msg\" WHERE id >= $idx - 100 AND id <= $idx + 100;
}
}
if (!$update)
{
if ($single_or_multi)
{
eval INSERT INTO t1(msg, id) VALUES (\"$msg\", $idx) ON DUPLICATE KEY UPDATE msg=VALUES(msg), id = VALUES(id);
}
if (!$single_or_multi)
{
let $diff = 200;
while ($diff)
{
eval INSERT INTO t1(msg, id) VALUES (\"$msg\", $idx + 100 - $diff) ON DUPLICATE KEY UPDATE msg=VALUES(msg), id=VALUES(id);
dec $diff;
}
}
}
}
if (!$cnt)
{
let $null_msg = `select floor(rand()*2)`;
if ($null_msg)
{
eval INSERT INTO t1(id,msg) VALUES ($idx, NULL);
}
if (!$null_msg)
{
eval INSERT INTO t1(id, msg) VALUES ($idx, \"$msg\");
}
}
}
if (!$insert_or_update)
{
if ($single_or_multi)
{
eval DELETE from t1 WHERE id=$idx;
}
if (!$single_or_multi)
{
eval DELETE from t1 WHERE id >= $idx - 100 AND id <= $idx + 100;
}
}
dec $commit_count;
if (!$commit_count)
{
let $commit_count= $commit_iterations;
COMMIT;
BEGIN;
}
dec $num_ops_ind;
}
COMMIT;
# final cleanup
DROP TABLE t1;
# restore innodb_file_format and innodb_file_format_max
eval SET GLOBAL innodb_file_format = \"$file_format_save\";
eval SET GLOBAL innodb_file_format_max = \"$file_format_max_save\";
eval SET GLOBAL innodb_simulate_comp_failures = $simulate_comp_failures_save;
--enable_query_log