From 91bc9cc9e66d55e003e90a206a1771c9f27d54b1 Mon Sep 17 00:00:00 2001 From: Guilhem Bichot Date: Fri, 5 Dec 2008 22:11:46 +0100 Subject: Fix for BUG#41037 "Maria: recovery failure (pushbuild2)" (checkpoint bug). mysql-test/suite/maria/r/maria-recovery3.result: result. mysql-test/suite/maria/t/maria-recovery3-master.opt: usual recovery test options mysql-test/suite/maria/t/maria-recovery3.test: Test for BUG#41037. Without the bugfix, the test would hang because Recovery would fail with "undo_key_insert got error 126": Recovery would believe INSERT of 2 is uncommitted, try to execute its UNDO_KEY_INSERT, fail to find the key to delete because DELETE deleted it. That failure of _ma_ck_real_delete() would mark table as corrupted (see in d_search()) which is error 126 (HA_ERR_CRASHED). storage/maria/ma_blockrec.c: set trn->rec_lsn to LSN of commit record, when writing it. storage/maria/ma_blockrec.h: new function storage/maria/ma_commit.c: when committing or rolling back, rec_lsn should be LSN_IMPOSSIBLE: assertion is moved here from trnman_end_trn(), because now ma_commit() can set rec_lsn and so when we reach trnman_end_trn() it's not LSN_IMPOSSIBLE anymore. Adding debug possibility to pause between COMMIT record write and trnman_commit_trn(), to be able to fire checkpoint in between. storage/maria/ma_loghandler.c: in-write hook for COMMIT records storage/maria/ma_recovery.c: More debugging info in maria_recovery.trace, to see how the starting point of REDO phase is determined storage/maria/trnman.c: assertion cannot be here anymore see ma_commit.c --- mysql-test/suite/maria/t/maria-recovery3.test | 71 +++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 mysql-test/suite/maria/t/maria-recovery3.test (limited to 'mysql-test/suite/maria/t/maria-recovery3.test') diff --git a/mysql-test/suite/maria/t/maria-recovery3.test b/mysql-test/suite/maria/t/maria-recovery3.test new file mode 100644 index 00000000000..68cc67fd328 --- /dev/null +++ b/mysql-test/suite/maria/t/maria-recovery3.test @@ -0,0 +1,71 @@ +--source include/not_embedded.inc +# Don't test this under valgrind, memory leaks will occur as we crash +--source include/not_valgrind.inc +# Binary must be compiled with debug for crash to occur +--source include/have_debug.inc +--source include/have_maria.inc + +set global maria_log_file_size=4294967295; +let $MARIA_LOG=../tmp; + +--disable_warnings +drop database if exists mysqltest; +--enable_warnings +create database mysqltest; +let $mms_tname=t; + +# Include scripts can perform SQL. For it to not influence the main test +# they use a separate connection. This way if they use a DDL it would +# not autocommit in the main test. +connect (admin, 127.0.0.1, root,,mysqltest,,); +--enable_reconnect + +connection default; +use mysqltest; +--enable_reconnect + +let $mms_tables=1; +let $mvr_restore_old_snapshot=0; +let $mms_compare_physically=0; +let $mvr_debug_option="+d,maria_flush_whole_log,maria_crash"; +let $mvr_crash_statement= set global maria_checkpoint_interval=1; + +-- source include/maria_empty_logs.inc + +# Test for BUG#41037 (recovery failure) +--echo * TEST of Checkpoint between writing the commit log record and committing in trnman +# we want recovery to use the tables as they were at time of crash +let $mvr_restore_old_snapshot=0; +# UNDO phase prevents physical comparison, normally, +# so we'll only use checksums to compare. +let $mms_compare_physically=0; +let $mvr_crash_statement= set global maria_checkpoint_interval=1; +create table t1(a int primary key) engine=maria; +insert into t1 values(1); +-- source include/maria_make_snapshot_for_comparison.inc +set session debug="+d,maria_sleep_in_commit"; +send insert into t1 values(2); +sleep 1; +# Now the INSERT of 2 has written a commit record +# but not yet called trnman_commit(), so for checkpoint it's not +# committed. +connection admin; +set global maria_checkpoint_interval=1000; # force a checkpoint +connection default; +reap; # end of INSERT +delete from t1 where a=2; +# Bug was that: Recovery starts REDO scanning from too far: from +# Checkpoint record which says INSERT is not committed, so +# Recovery executes the INSERT's UNDO and finds no key to delete +# (as DELETE already deleted it), fails. +-- source include/maria_verify_recovery.inc +drop table t1; + +# Note that even if machine is loaded and thus INSERT is committed +# before checkpoint happens, test should still pass (though it won't +# reproduce the conditions of the bug). + +# clean up everything +let $mms_purpose=comparison; +eval drop database mysqltest_for_$mms_purpose; +drop database mysqltest; -- cgit v1.2.1