| 1 |
# |
| 2 |
# WL#6915: InnoDB: Undo logs for temp-tables (and related objects) should |
| 3 |
# reside in temp-tablespace |
| 4 |
# |
| 5 |
--source include/have_debug.inc |
| 6 |
|
| 7 |
# Valgrind can hang or return spurious messages on DBUG_SUICIDE |
| 8 |
--source include/not_valgrind.inc |
| 9 |
# Avoid CrashReporter popup on Mac |
| 10 |
--source include/not_crashrep.inc |
| 11 |
|
| 12 |
# In the test scenario, there can be orphaned .frm files. |
| 13 |
# These are expected. So suppressing the associated warnings. |
| 14 |
call mtr.add_suppression("\\[ERROR\\] .*MY-\\d+.* table .* does not exist " |
| 15 |
"in the InnoDB internal"); |
| 16 |
call mtr.add_suppression("Found .* prepared XA transactions"); |
| 17 |
|
| 18 |
################################################################################ |
| 19 |
# |
| 20 |
# Will test following scenarios: |
| 21 |
# 1. Hitting crash while preparing xa trx. |
| 22 |
# 2. Hitting crash while committing normal trx involving temp/non-temp tables. |
| 23 |
# 3. try to start server with different values of innodb_rollback_segments. |
| 24 |
# (try scenario such that a rollback segment is shared by multiple trxs). |
| 25 |
# |
| 26 |
################################################################################ |
| 27 |
|
| 28 |
#----------------------------------------------------------------------------- |
| 29 |
# |
| 30 |
# create test-bed |
| 31 |
# |
| 32 |
|
| 33 |
set global innodb_file_per_table = off; |
| 34 |
let $MYSQL_TMP_DIR = `select @@tmpdir`; |
| 35 |
let $MYSQL_DATA_DIR = `select @@datadir`; |
| 36 |
let SEARCH_FILE = $MYSQLTEST_VARDIR/log/my_restart.err; |
| 37 |
let $args = --loose-console > $SEARCH_FILE 2>&1; |
| 38 |
let crash = $args --innodb-force-recovery-crash; |
| 39 |
|
| 40 |
#----------------------------------------------------------------------------- |
| 41 |
# |
| 42 |
# 1. Hitting crash while preparing xa trx. |
| 43 |
# |
| 44 |
--echo # The use of temporary tables inside XA transactions is only permitted |
| 45 |
--echo # when xa_detach_on_prepare is OFF. |
| 46 |
--let $CURSESS_xa_detach_on_prepare = `SELECT @@SESSION.xa_detach_on_prepare` |
| 47 |
SET SESSION xa_detach_on_prepare = OFF; |
| 48 |
create temporary table t1 (i int) engine=innodb; |
| 49 |
create table t2 (i int) engine=innodb; |
| 50 |
# |
| 51 |
insert into t2 values (301); |
| 52 |
xa start 'tx2'; |
| 53 |
insert into t1 values (2), (3); |
| 54 |
insert into t2 values (202), (303); |
| 55 |
select * from t1; |
| 56 |
select * from t2; |
| 57 |
xa end 'tx2'; |
| 58 |
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 59 |
set session debug="+d,ib_trx_crash_during_xa_prepare_step"; |
| 60 |
--error 2013 |
| 61 |
xa prepare 'tx2'; |
| 62 |
# |
| 63 |
--enable_reconnect |
| 64 |
--source include/wait_until_connected_again.inc |
| 65 |
--disable_reconnect |
| 66 |
# |
| 67 |
select * from t2; |
| 68 |
drop table t2; |
| 69 |
--replace_result $CURSESS_xa_detach_on_prepare OLD_VALUE_xa_detach_on_prepare |
| 70 |
--eval SET SESSION xa_detach_on_prepare = $CURSESS_xa_detach_on_prepare |
| 71 |
|
| 72 |
#----------------------------------------------------------------------------- |
| 73 |
# |
| 74 |
# 2. Hitting crash while committing normal trx involving temp/non-temp tables. |
| 75 |
# |
| 76 |
use test; |
| 77 |
create temporary table t1 |
| 78 |
(a int, b char(100), c char(100)) engine = innodb; |
| 79 |
create table t2 |
| 80 |
(a int, b char(100), c char(100)) engine = innodb; |
| 81 |
delimiter |; |
| 82 |
create procedure populate_t1_t2() |
| 83 |
begin |
| 84 |
declare i int default 1; |
| 85 |
while (i <= 50) DO |
| 86 |
insert into t1 values (i, 'a', 'b'); |
| 87 |
insert into t2 values (i, 'a', 'b'); |
| 88 |
set i = i + 1; |
| 89 |
end while; |
| 90 |
end| |
| 91 |
delimiter ;| |
| 92 |
call populate_t1_t2; |
| 93 |
begin; |
| 94 |
call populate_t1_t2(); |
| 95 |
update t1 set a = a + 1; |
| 96 |
update t2 set a = a + 1; |
| 97 |
select count(*) from t1; |
| 98 |
select count(*) from t2; |
| 99 |
--source include/expect_crash.inc |
| 100 |
set session debug="+d,ib_trx_crash_during_commit"; |
| 101 |
# With bin-log enabled, COMMIT prepares the transaction before doing SE commit. |
| 102 |
# So on restart, the prepared trx is recovered. Without bin-log, the trx would |
| 103 |
# have been rolled back. Hence, crashing before commit. |
| 104 |
--disable_query_log |
| 105 |
if (`SELECT @@log_bin = 1`) |
| 106 |
{ |
| 107 |
set session debug="+d,crash_commit_before"; |
| 108 |
} |
| 109 |
--enable_query_log |
| 110 |
--error 2013 |
| 111 |
commit; |
| 112 |
# |
| 113 |
--enable_reconnect |
| 114 |
--source include/start_mysqld.inc |
| 115 |
--source include/wait_until_connected_again.inc |
| 116 |
--disable_reconnect |
| 117 |
# |
| 118 |
select count(*) from t2; |
| 119 |
drop table t2; |
| 120 |
drop procedure populate_t1_t2; |
| 121 |
|
| 122 |
#----------------------------------------------------------------------------- |
| 123 |
# |
| 124 |
# 3. try to start server with different values of innodb_rollback_segments. |
| 125 |
# (try scenario such that a rollback segment is shared by multiple trxs). |
| 126 |
# |
| 127 |
let $restart_parameters = restart: --innodb_rollback_segments=1; |
| 128 |
--source include/restart_mysqld.inc |
| 129 |
# |
| 130 |
create table t (i int) engine=innodb; |
| 131 |
insert into t values (1); |
| 132 |
insert into t values (2); |
| 133 |
create temporary table t2 (i int) engine=innodb; |
| 134 |
insert into t values (1); |
| 135 |
insert into t values (2); |
| 136 |
drop table t; |
| 137 |
drop table t2; |
| 138 |
# |
| 139 |
connect (con1,localhost,root,,); |
| 140 |
connect (con2,localhost,root,,); |
| 141 |
# |
| 142 |
connection default; |
| 143 |
delimiter |; |
| 144 |
create procedure populate_t1_t2() |
| 145 |
begin |
| 146 |
declare i int default 1; |
| 147 |
while (i <= 100) DO |
| 148 |
insert into t1 values (i, 'a', 'b'); |
| 149 |
insert into t2 values (i, 'a', 'b'); |
| 150 |
set i = i + 1; |
| 151 |
end while; |
| 152 |
end| |
| 153 |
delimiter ;| |
| 154 |
create table t2 |
| 155 |
(a int, b char(100), c char(100)) engine = innodb; |
| 156 |
# |
| 157 |
connection con1; |
| 158 |
create temporary table t1 |
| 159 |
(a int, b char(100), c char(100)) engine = innodb; |
| 160 |
call populate_t1_t2(); |
| 161 |
select count(*) from t1; |
| 162 |
drop table t1; |
| 163 |
# |
| 164 |
connection con2; |
| 165 |
create temporary table t1 |
| 166 |
(a int, b char(100), c char(100)) engine = innodb; |
| 167 |
call populate_t1_t2(); |
| 168 |
commit; |
| 169 |
select count(*) from t1; |
| 170 |
drop table t1; |
| 171 |
# |
| 172 |
connection default; |
| 173 |
drop table t2; |
| 174 |
drop procedure populate_t1_t2; |
| 175 |
# |
| 176 |
# trying with value innodb_rollback_segments = 1 (so only slot-0 redo rseg is active) |
| 177 |
# |
| 178 |
let $restart_parameters = restart: --innodb_rollback_segments=1; |
| 179 |
--source include/restart_mysqld.inc |
| 180 |
# |
| 181 |
create table t (i int) engine=innodb; |
| 182 |
insert into t values (1); |
| 183 |
insert into t values (2); |
| 184 |
create temporary table t2 (i int) engine=innodb; |
| 185 |
insert into t values (1); |
| 186 |
insert into t values (2); |
| 187 |
drop table t; |
| 188 |
drop table t2; |
| 189 |
# |
| 190 |
# trying with value innodb_rollback_segments = 8 (this will make 8 redo rseg active). |
| 191 |
# |
| 192 |
let $restart_parameters = restart: --innodb_rollback_segments=8; |
| 193 |
--source include/restart_mysqld.inc |
| 194 |
# |
| 195 |
create table t (i int) engine=innodb; |
| 196 |
insert into t values (1); |
| 197 |
insert into t values (2); |
| 198 |
insert into t values (2); |
| 199 |
insert into t values (2); |
| 200 |
insert into t values (2); |
| 201 |
create temporary table t2 (i int) engine=innodb; |
| 202 |
insert into t values (1); |
| 203 |
insert into t values (2); |
| 204 |
insert into t values (2); |
| 205 |
insert into t values (2); |
| 206 |
insert into t values (2); |
| 207 |
insert into t values (2); |
| 208 |
drop table t; |
| 209 |
drop table t2; |
| 210 |
|
| 211 |
--let $restart_parameters= restart: |
| 212 |
--source include/restart_mysqld.inc |