Commit a2d921be authored by unknown's avatar unknown

MWL#116: Add two more test cases:

 - Test internal 2-phase commit when binlog is enabled globally, but disabled in the session
 - Test crashing at various points during commit
parent 805f0093
CREATE TABLE t1(a CHAR(255),
b CHAR(255),
c CHAR(255),
d CHAR(255),
id INT AUTO_INCREMENT,
PRIMARY KEY(id)) ENGINE=InnoDB;
create table t2 like t1;
create procedure setcrash(IN i INT)
begin
CASE i
WHEN 1 THEN SET SESSION debug="d,crash_commit_after_prepare";
WHEN 2 THEN SET SESSION debug="d,crash_commit_after_log";
WHEN 3 THEN SET SESSION debug="d,crash_commit_before_unlog";
WHEN 4 THEN SET SESSION debug="d,crash_commit_after";
WHEN 5 THEN SET SESSION debug="d,crash_commit_before";
ELSE BEGIN END;
END CASE;
end //
FLUSH TABLES;
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
RESET MASTER;
START TRANSACTION;
insert into t1 select * from t2;
call setcrash(5);
COMMIT;
Got one of the listed errors
SELECT * FROM t1 ORDER BY id;
a b c d id
SHOW BINLOG EVENTS LIMIT 2,1;
Log_name Pos Event_type Server_id End_log_pos Info
delete from t1;
RESET MASTER;
START TRANSACTION;
insert into t1 select * from t2;
call setcrash(4);
COMMIT;
Got one of the listed errors
SELECT * FROM t1 ORDER BY id;
a b c d id
a b c d 1
a b c d 2
a b c d 3
a b c d 4
a b c d 5
a b c d 6
a b c d 7
a b c d 8
a b c d 9
a b c d 10
SHOW BINLOG EVENTS LIMIT 2,1;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 174 Query 1 268 use `test`; insert into t1 select * from t2
delete from t1;
RESET MASTER;
START TRANSACTION;
insert into t1 select * from t2;
call setcrash(3);
COMMIT;
Got one of the listed errors
SELECT * FROM t1 ORDER BY id;
a b c d id
a b c d 1
a b c d 2
a b c d 3
a b c d 4
a b c d 5
a b c d 6
a b c d 7
a b c d 8
a b c d 9
a b c d 10
SHOW BINLOG EVENTS LIMIT 2,1;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 174 Query 1 268 use `test`; insert into t1 select * from t2
delete from t1;
RESET MASTER;
START TRANSACTION;
insert into t1 select * from t2;
call setcrash(2);
COMMIT;
Got one of the listed errors
SELECT * FROM t1 ORDER BY id;
a b c d id
a b c d 1
a b c d 2
a b c d 3
a b c d 4
a b c d 5
a b c d 6
a b c d 7
a b c d 8
a b c d 9
a b c d 10
SHOW BINLOG EVENTS LIMIT 2,1;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 174 Query 1 268 use `test`; insert into t1 select * from t2
delete from t1;
RESET MASTER;
START TRANSACTION;
insert into t1 select * from t2;
call setcrash(1);
COMMIT;
Got one of the listed errors
SELECT * FROM t1 ORDER BY id;
a b c d id
SHOW BINLOG EVENTS LIMIT 2,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 table if exists t1, t2;
SET binlog_format = 'mixed';
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb;
CREATE TABLE t2 (b INT PRIMARY KEY) ENGINE=pbxt;
BEGIN;
SELECT @@log_bin;
@@log_bin
1
INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (2);
COMMIT;
select * from t1;
a
1
select * from t2;
b
2
SET sql_log_bin = 0;
INSERT INTO t1 VALUES (3);
INSERT INTO t2 VALUES (4);
COMMIT;
select * from t1 order by a;
a
1
3
select * from t2 order by b;
b
2
4
drop table t1, t2;
drop database pbxt;
--source include/have_innodb.inc
--source include/have_log_bin.inc
--disable_warnings
drop table if exists t1, t2;
--enable_warnings
SET binlog_format = 'mixed';
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb;
CREATE TABLE t2 (b INT PRIMARY KEY) ENGINE=pbxt;
BEGIN;
# verify that binlog is on
SELECT @@log_bin;
INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (2);
COMMIT;
select * from t1;
select * from t2;
# Test 2-phase commit when we disable binlogging.
SET sql_log_bin = 0;
INSERT INTO t1 VALUES (3);
INSERT INTO t2 VALUES (4);
COMMIT;
select * from t1 order by a;
select * from t2 order by b;
drop table t1, t2;
drop database pbxt;
--skip-stack-trace --skip-core-file
# Testing group commit by crashing a few times.
# Test adapted from the Facebook patch: lp:mysqlatfacebook
--source include/not_embedded.inc
# Don't test this under valgrind, memory leaks will occur
--source include/not_valgrind.inc
# Binary must be compiled with debug for crash to occur
--source include/have_debug.inc
--source include/have_innodb.inc
--source include/have_log_bin.inc
let $file_format_check=`SELECT @@innodb_file_format_check`;
CREATE TABLE t1(a CHAR(255),
b CHAR(255),
c CHAR(255),
d CHAR(255),
id INT AUTO_INCREMENT,
PRIMARY KEY(id)) ENGINE=InnoDB;
create table t2 like t1;
delimiter //;
create procedure setcrash(IN i INT)
begin
CASE i
WHEN 1 THEN SET SESSION debug="d,crash_commit_after_prepare";
WHEN 2 THEN SET SESSION debug="d,crash_commit_after_log";
WHEN 3 THEN SET SESSION debug="d,crash_commit_before_unlog";
WHEN 4 THEN SET SESSION debug="d,crash_commit_after";
WHEN 5 THEN SET SESSION debug="d,crash_commit_before";
ELSE BEGIN END;
END CASE;
end //
delimiter ;//
# Avoid getting a crashed mysql.proc table.
FLUSH TABLES;
let $numtests = 5;
let $numinserts = 10;
while ($numinserts)
{
dec $numinserts;
INSERT INTO t2(a, b, c, d) VALUES ('a', 'b', 'c', 'd');
}
--enable_reconnect
while ($numtests)
{
RESET MASTER;
START TRANSACTION;
insert into t1 select * from t2;
# Write file to make mysql-test-run.pl expect crash
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
eval call setcrash($numtests);
# 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
# table and binlog should be in sync.
SELECT * FROM t1 ORDER BY id;
SHOW BINLOG EVENTS LIMIT 2,1;
delete from t1;
dec $numtests;
}
# final cleanup
DROP TABLE t1;
DROP TABLE t2;
DROP PROCEDURE setcrash;
--disable_query_log
eval SET GLOBAL innodb_file_format_check=$file_format_check;
--enable_query_log
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment