Skip to content

Commit

Permalink
SQL: TRT fix for crash_commit_after [#305, #302]
Browse files Browse the repository at this point in the history
Tests affected: innodb.group_commit_crash (verbosity improved)
  • Loading branch information
midenok committed Nov 17, 2017
1 parent ab04950 commit 2b60afe
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 22 deletions.
40 changes: 28 additions & 12 deletions mysql-test/suite/innodb/r/group_commit_crash.result
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ d CHAR(255),
id INT,
PRIMARY KEY(id)) ENGINE=InnoDB;
create table t2 like t1;
create procedure setcrash(IN i INT)
create function getcrash(i INT)
returns VARCHAR(255)
begin
CASE i
WHEN 1 THEN SET SESSION debug_dbug="d,crash_commit_after_prepare";
WHEN 2 THEN SET SESSION debug_dbug="d,crash_commit_after_log";
WHEN 3 THEN SET SESSION debug_dbug="d,crash_commit_before_unlog";
WHEN 4 THEN SET SESSION debug_dbug="d,crash_commit_after";
WHEN 5 THEN SET SESSION debug_dbug="d,crash_commit_before";
WHEN 1 THEN RETURN "crash_commit_after_prepare";
WHEN 2 THEN RETURN "crash_commit_after_log";
WHEN 3 THEN RETURN "crash_commit_before_unlog";
WHEN 4 THEN RETURN "crash_commit_after";
WHEN 5 THEN RETURN "crash_commit_before";
ELSE BEGIN END;
END CASE;
end //
Expand All @@ -31,9 +32,12 @@ SET binlog_format= mixed;
RESET MASTER;
START TRANSACTION;
insert into t1 select * from t2;
call setcrash(5);
SET @crash= getcrash(5);
SET SESSION debug_dbug=concat("d,", @crash);
COMMIT;
Got one of the listed errors
CRASH_POINT
crash_commit_before
SELECT * FROM t1 ORDER BY id;
a b c d id
SHOW BINLOG EVENTS LIMIT 4,1;
Expand All @@ -43,9 +47,12 @@ SET binlog_format= mixed;
RESET MASTER;
START TRANSACTION;
insert into t1 select * from t2;
call setcrash(4);
SET @crash= getcrash(4);
SET SESSION debug_dbug=concat("d,", @crash);
COMMIT;
Got one of the listed errors
CRASH_POINT
crash_commit_after
SELECT * FROM t1 ORDER BY id;
a b c d id
a b c d 1
Expand All @@ -66,9 +73,12 @@ SET binlog_format= mixed;
RESET MASTER;
START TRANSACTION;
insert into t1 select * from t2;
call setcrash(3);
SET @crash= getcrash(3);
SET SESSION debug_dbug=concat("d,", @crash);
COMMIT;
Got one of the listed errors
CRASH_POINT
crash_commit_before_unlog
SELECT * FROM t1 ORDER BY id;
a b c d id
a b c d 1
Expand All @@ -89,9 +99,12 @@ SET binlog_format= mixed;
RESET MASTER;
START TRANSACTION;
insert into t1 select * from t2;
call setcrash(2);
SET @crash= getcrash(2);
SET SESSION debug_dbug=concat("d,", @crash);
COMMIT;
Got one of the listed errors
CRASH_POINT
crash_commit_after_log
SELECT * FROM t1 ORDER BY id;
a b c d id
a b c d 1
Expand All @@ -112,14 +125,17 @@ SET binlog_format= mixed;
RESET MASTER;
START TRANSACTION;
insert into t1 select * from t2;
call setcrash(1);
SET @crash= getcrash(1);
SET SESSION debug_dbug=concat("d,", @crash);
COMMIT;
Got one of the listed errors
CRASH_POINT
crash_commit_after_prepare
SELECT * FROM t1 ORDER BY id;
a b c d id
SHOW BINLOG EVENTS LIMIT 4,1;
Log_name Pos Event_type Server_id End_log_pos Info
delete from t1;
DROP TABLE t1;
DROP TABLE t2;
DROP PROCEDURE setcrash;
DROP FUNCTION getcrash;
23 changes: 14 additions & 9 deletions mysql-test/suite/innodb/t/group_commit_crash.test
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ CREATE TABLE t1(a CHAR(255),
PRIMARY KEY(id)) ENGINE=InnoDB;
create table t2 like t1;
delimiter //;
create procedure setcrash(IN i INT)
create function getcrash(i INT)
returns VARCHAR(255)
begin
CASE i
WHEN 1 THEN SET SESSION debug_dbug="d,crash_commit_after_prepare";
WHEN 2 THEN SET SESSION debug_dbug="d,crash_commit_after_log";
WHEN 3 THEN SET SESSION debug_dbug="d,crash_commit_before_unlog";
WHEN 4 THEN SET SESSION debug_dbug="d,crash_commit_after";
WHEN 5 THEN SET SESSION debug_dbug="d,crash_commit_before";
WHEN 1 THEN RETURN "crash_commit_after_prepare";
WHEN 2 THEN RETURN "crash_commit_after_log";
WHEN 3 THEN RETURN "crash_commit_before_unlog";
WHEN 4 THEN RETURN "crash_commit_after";
WHEN 5 THEN RETURN "crash_commit_before";
ELSE BEGIN END;
END CASE;
end //
Expand Down Expand Up @@ -53,15 +54,19 @@ while ($numtests)
# Write file to make mysql-test-run.pl expect crash
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect

eval call setcrash($numtests);

eval SET @crash= getcrash($numtests);
SET SESSION debug_dbug=concat("d,", @crash);
# Run the crashing query
--error 2006,2013
COMMIT;

# Poll the server waiting for it to be back online again.
--source include/wait_until_connected_again.inc

--disable_query_log
eval SET @crash= getcrash($numtests);
SELECT @crash as CRASH_POINT;
--enable_query_log
# table and binlog should be in sync.
SELECT * FROM t1 ORDER BY id;
--replace_column 2 # 5 #
Expand All @@ -75,4 +80,4 @@ while ($numtests)
# final cleanup
DROP TABLE t1;
DROP TABLE t2;
DROP PROCEDURE setcrash;
DROP FUNCTION getcrash;
2 changes: 1 addition & 1 deletion sql/handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,7 @@ int ha_commit_trans(THD *thd, bool all)
if (trt.update())
goto err;
if (all)
trans_commit_stmt(thd);
commit_one_phase_2(thd, false, &thd->transaction.stmt, false);
break;
}
}
Expand Down

0 comments on commit 2b60afe

Please sign in to comment.