mariadb/mysql-test/t/myisam-metadata.test
Kristian Nielsen 8e63a7fe27 Yet another attempt at fixing random failures in test case main.myisam-metadata
I think I finally found the problem, managed to reproduce locally using a
sleep in the test case to simulate the particular race condition that causes
the test to fail often in Buildbot.

The test starts an ALTER TABLE that does repair by sort in one thread, then
another thread waits for the sort to be visible in SHOW PROCESSLIST and runs a
SHOW statement in parallel.

The problem happens when the sort manages to run to completion before the
other thread has the time to look at SHOW PROCESSLIST. In this case, the wait
times out because the state looked for has already passed.

Earlier I added some DEBUG_SYNC to prevent this race, but it turns out that
DEBUG_SYNC itself changes the state in the processlist. So when the debug sync
point was hit, the processlist was showing the wrong state, so the wait would
still time out.

Fixed now by looking for the processlist to contain either the "Repair by
sorting" state or the debug sync wait stage.

Also clean up previous attempts to fix it. Set the wait timeout back to
reasonable 60 seconds, and simplify the DEBUG_SYNC operations to work closer
to how the original test case was intended.
2014-10-29 13:39:22 +01:00

59 lines
1.4 KiB
Text

#
# Test bugs in MyISAM that may cause problems for metadata
#
--source include/big_test.inc
--source include/have_debug_sync.inc
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
#
# LP:989055 - Querying myisam table metadata may corrupt the table
#
CREATE TABLE t1 (
id INT PRIMARY KEY,
a VARCHAR(100),
INDEX(a)
) ENGINE=MyISAM;
ALTER TABLE t1 DISABLE KEYS;
let $1=100000;
--disable_query_log
while ($1)
{
eval insert into t1 values($1, "line number $1");
dec $1;
}
--enable_query_log
--connect(con1,localhost,root,,)
# Set a debug_sync waitpoint.
# This is just to ensure that the ALTER does not have time to complete
# its operation and change the status away from "Repair by sorting" before
# wait_condition has a chance to see it.
SET debug_sync= 'myisam_after_repair_by_sort WAIT_FOR go';
send
ALTER TABLE t1 ENABLE KEYS;
--connection default
--let $wait_timeout=60
--let $show_statement= SHOW PROCESSLIST
--let $field= State
# If the sort completes early and we hit the debug_sync point, the processlist
# will show the debug_sync state, so we need to check for that also.
--let $condition= RLIKE 'Repair by sorting|myisam_after_repair_by_sort'
--source include/wait_show_condition.inc
SET debug_sync= 'now SIGNAL go';
--replace_column 7 # 8 # 9 # 12 # 13 # 14 #
SHOW TABLE STATUS LIKE 't1';
--connection con1
--reap
--connection default
--disconnect con1
DROP TABLE t1;
set debug_sync='reset';