Debian Codegraph @

mysql-test/suite/ndb/t/ndb_alter_table_temp_files_cleanup.test

raw
1 --source include/have_ndb.inc
2 --source include/have_debug.inc
3
4 #
5 # BUG#24935788 COPYING ALTER LEAVES EXTRANEOUS TEMPORARY TABLE AND FOREIGN KEYS
6 # During this test aims to reproduce bug with given conditions:
7 # - at least two tables
8 # - one table contains foreign keys
9 # - simulate failure of mysqld during copying alter table
10 # This should lead to situation where:
11 # - foreign keys refers to temporary table
12 # - having left behind temporary tables may break operations such as alter table or mysqldump:
13 # * according to bugs #24935788 and #29892252
14 #
15 --disable_query_log ONCE
16 call mtr.add_suppression("Found temporary table test.#sql-[a-z0-9_]+.+");
17
18 --echo # create table t1
19 CREATE TABLE t1(
20 a INT PRIMARY KEY,
21 b INT UNIQUE KEY
22 )ENGINE = NDB;
23
24 --echo # create table t2 with fks referring columns from t1
25 CREATE TABLE t2(
26 a INT,
27 b INT,
28 c INT UNIQUE KEY,
29 CONSTRAINT fk1 FOREIGN KEY (a) REFERENCES t1(a),
30 CONSTRAINT fk2 FOREIGN KEY (b) REFERENCES t1(b)
31 )ENGINE = NDB;
32
33 INSERT INTO t1 VALUES (1,10), (2,20), (3,30), (4,40);
34 INSERT INTO t2 VALUES (1,10,100), (2,20,200);
35
36 --echo # mysqld will crash during alter table and leave temporary named table behind
37 SET debug='+d,ndb_simulate_crash_during_alter_table_rename1';
38 --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.1.expect
39 --error 2013,2003
40 ALTER TABLE t1 ALGORITHM=COPY;
41 --echo # mysqld will restart after crash and remove the temporary named table during connecting to the cluster
42 --enable_reconnect
43 --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.1.expect
44 --source include/wait_until_connected_again.inc
45
46 --let $assert_text=require temporary table warning message
47 --let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.1.1.err
48 --let $assert_select=Found temporary table test.#sql-[a-z0-9_]+.+
49 --let $assert_count=1
50 --source include/assert_grep.inc
51
52 --echo # verify that no temporary table left
53 SELECT count(*) FROM ndbinfo.dict_obj_info WHERE REGEXP_LIKE(fq_name, '#sql');
54
55 --echo # verify that original data has not been affected by temporary table cleanup
56 SELECT a, b FROM t1 ORDER BY a;
57 SELECT a, b, c FROM t2 ORDER BY a;
58
59 --echo # cleanup
60 DROP TABLE t2, t1;