mariadb/mysql-test/t/myisam_crash_before_flush_keys.test
Sergey Vojtovich 40ec012c90 Backport from 6.0-codebase.
WL#3951 - MyISAM: Additional Error Logs for Data Corruption

When table corruption is detected, in addition to current error message
provide following information:
- list of threads (and queries) accessing a table;
- thread_id of a thread that detected corruption;
- source file name and line number where this corruption was detected;
- optional extra information (string).

mysql-test/r/myisam_crash_before_flush_keys.result:
  Adjusted a test case according to WL#3951.
mysql-test/t/myisam_crash_before_flush_keys.test:
  Adjusted a test case according to WL#3951.
storage/myisam/CMakeLists.txt:
  Added mi_extrafunc.h to myisam sources list.
storage/myisam/Makefile.am:
  Added mi_extrafunc.h to myisam headers list.
storage/myisam/ha_myisam.cc:
  Added _mi_report_crashed() function (reports additional information
  whenever table corruption is detected).
storage/myisam/mi_extrafunc.h:
  All standalone programs must define their version of _mi_report_crashed()
  by including mi_extrafunc.h.
storage/myisam/mi_locking.c:
  For every call to mi_lock_database(F_[RD|WR|EXTRA_]LCK) - add
  current thread to the list of threads accessing this table.
  
  For every call to mi_lock_database(F_UNLCK) - remove current
  thread from the list of threads accessing this table.
storage/myisam/mi_test1.c:
  All standalone programs must define their version of _mi_report_crashed()
  by including mi_extrafunc.h.
storage/myisam/mi_test2.c:
  All standalone programs must define their version of _mi_report_crashed()
  by including mi_extrafunc.h.
storage/myisam/mi_test3.c:
  All standalone programs must define their version of _mi_report_crashed()
  by including mi_extrafunc.h.
storage/myisam/myisam_ftdump.c:
  All standalone programs must define their version of _mi_report_crashed()
  by including mi_extrafunc.h.
storage/myisam/myisamchk.c:
  All standalone programs must define their version of _mi_report_crashed()
  by including mi_extrafunc.h.
storage/myisam/myisamdef.h:
  Extra elements are added to MI_INFO and MYISAM_SHARE structures.
  MI_INFO is extended with LIST element, that holds a pointer to
  THD object accessing a table. MYISAM_SHARE is extended with LIST
  (list of threads accessing a table).
  
  Whenever table is marked as crashed, call mi_report_crashed() macro
  to provide useful information.
storage/myisam/myisamlog.c:
  All standalone programs must define their version of _mi_report_crashed()
  by including mi_extrafunc.h.
storage/myisam/myisampack.c:
  All standalone programs must define their version of _mi_report_crashed()
  by including mi_extrafunc.h.
storage/myisam/rt_test.c:
  All standalone programs must define their version of _mi_report_crashed()
  by including mi_extrafunc.h.
storage/myisam/sp_test.c:
  All standalone programs must define their version of _mi_report_crashed()
  by including mi_extrafunc.h.
storage/myisammrg/ha_myisammrg.cc:
  For each unedrlying table initialize `in_use' variable.
2009-11-25 16:25:01 +04:00

44 lines
1.4 KiB
Text

--echo #
--echo # BUG#41330 - Myisam table open count set to zero before index blocks are written.
--echo #
--source include/not_embedded.inc
--echo # Don't test this under valgrind, memory leaks will occur
--source include/not_valgrind.inc
--echo # Binary must be compiled with debug for crash to occur
--source include/have_debug.inc
call mtr.add_suppression("Got an error from thread_id=.*ha_myisam.cc:");
call mtr.add_suppression("MySQL thread id .*, query id .* localhost.*root Checking table");
let $MYSQLD_DATADIR= `select @@datadir`;
SET GLOBAL delay_key_write=ALL;
CREATE TABLE t1(a INT,
b INT,
PRIMARY KEY(a , b),
KEY(b)) ENGINE=MyISAM DELAY_KEY_WRITE = 1;
INSERT INTO t1 VALUES (1,2),(2,3),(3,4),(4,5),(5,6);
--echo # Setup the mysqld to crash at certain point
SET SESSION debug="d,crash_before_flush_keys";
--echo # Write file to make mysql-test-run.pl expect crash
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--echo # Run the crashing query
--error 2013
FLUSH TABLE t1;
--echo # Write file to make mysql-test-run.pl start the server
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--echo # Turn on reconnect
--enable_reconnect
--echo # Call script that will poll the server waiting for
--echo # it to be back online again
--source include/wait_until_connected_again.inc
# Must report that the table wasn't closed properly
CHECK TABLE t1;
DROP TABLE t1;