--source include/have_innodb.inc --source include/have_sequence.inc # Skip unless strace and passwordless sudo are available --perl my $ok = system("which strace >/dev/null 2>&1") == 0 && system("sudo -n true >/dev/null 2>&1") == 0; open(F, ">$ENV{MYSQLTEST_VARDIR}/tmp/mdev41703_skip.inc") or die $!; print F ($ok ? "" : "--skip needs strace and passwordless sudo\n"); close F; EOF --source $MYSQLTEST_VARDIR/tmp/mdev41703_skip.inc # The bug writes these to the error log; don't let MTR's log scan hide the real failure call mtr.add_suppression("InnoDB indexes are inconsistent with what defined in .frm"); call mtr.add_suppression("InnoDB: Table test/t[45] contains .* indexes inside InnoDB"); call mtr.add_suppression("InnoDB could not find key no"); call mtr.add_suppression("InnoDB: change_active_index.* failed"); --let $failures= 0 --let $pid_file= `SELECT @@pid_file` --let $helper= $MYSQL_TEST_DIR/std_data/strace_inject.sh --let $trace4= $MYSQLTEST_VARDIR/tmp/mdev41703_t1.trace --let $trace5= $MYSQLTEST_VARDIR/tmp/mdev41703_t2.trace CREATE TABLE t1 (id INT PRIMARY KEY, k INT, n INT, v TEXT, KEY ix2_t1 (k, n)) ENGINE=InnoDB; INSERT INTO t1 SELECT seq, seq % 7, seq % 11, REPEAT('v', 20) FROM seq_1_to_55; CREATE TABLE t2 (id INT PRIMARY KEY, k INT) ENGINE=InnoDB; INSERT INTO t2 SELECT seq, seq FROM seq_1_to_20; CHECKSUM TABLE t1, t2; --echo # Case 1: DROP INDEX with EIO injected on the first rename() --exec sh $helper start $pid_file $trace4 --replace_regex /#sql-alter-[0-9a-f-]+/#sql-alter-X/ --error ER_ERROR_ON_RENAME ALTER TABLE t1 DROP INDEX ix2_t1; --exec sh $helper stop $pid_file $trace4 --echo # injected renames (must be 1, else the injection missed): --exec grep -c 'INJECTED' $trace4 --let $tbl= t1 --let $phase= after_fail --source include/mdev41703_check.inc --echo # indexed lookup on t1 (uses ix2_t1): --error 0,ER_GET_ERRNO SELECT id FROM t1 WHERE k=3 AND n=3; --echo errno: $mysql_errno if ($mysql_errno) { --echo FAIL: t1: indexed lookup failed with errno $mysql_errno --inc $failures } --echo # workaround, avoids the stale index (data is intact): SELECT COUNT(*) FROM t1 IGNORE INDEX (ix2_t1); --echo # Case 2: CREATE INDEX with EIO injected on the first rename() --exec sh $helper start $pid_file $trace5 --replace_regex /#sql-alter-[0-9a-f-]+/#sql-alter-X/ --error ER_ERROR_ON_RENAME ALTER TABLE t2 ADD INDEX ix_k (k); --exec sh $helper stop $pid_file $trace5 --echo # injected renames (must be 1): --exec grep -c 'INJECTED' $trace5 --let $tbl= t2 --let $phase= after_fail --source include/mdev41703_check.inc --echo # FORCE INDEX (ix_k): 0 = index usable, 1176 = index gone (both are consistent) --error 0,ER_KEY_DOES_NOT_EXISTS SELECT COUNT(*) FROM t2 FORCE INDEX (ix_k); --echo errno: $mysql_errno --echo # Consistency must survive a restart --source include/restart_mysqld.inc --let $tbl= t1 --let $phase= after_restart --source include/mdev41703_check.inc --let $tbl= t2 --let $phase= after_restart --source include/mdev41703_check.inc --remove_file $trace4 --remove_file $trace5 DROP TABLE t1, t2; if ($failures) { --die MDEV-41703 reproduced: $failures consistency check(s) failed } --echo # all consistency checks passed