Debian Codegraph @

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

raw
1 --source include/have_ndb.inc
2 --source suite/ndb/include/backup_restore_setup.inc
3
4 #
5 # NOTE! This test restarts the data nodes with the special parameter
6 # __at_restart_skip_indexes which causes indexes to be skipped during restart.
7 #
8
9 # Ignore the warning generated by ndbcluster's binlog thread
10 # when cluster is restarted
11 --disable_query_log
12 call mtr.add_suppression("cluster disconnect An incident event has been written");
13 # These failures occurs when NDB is restarted without indexes
14 call mtr.add_suppression("Failed to setup PRIMARY index of ndb_sql_metadata");
15 call mtr.add_suppression("stored grants: not initialized.");
16 call mtr.add_suppression("stored grants: failed to apply stored grants.");
17 --enable_query_log
18
19 # Ignore the warning generated by ndbcluster's binlog thread
20 # when cluster is restarted - also on the second mysqld
21 connect(mysqld2,127.0.0.1,root,,test,$MASTER_MYPORT1);
22 connection mysqld2;
23 --disable_query_log
24 call mtr.add_suppression("cluster disconnect An incident event has been written");
25 # These failures occurs when NDB is restarted without indexes
26 call mtr.add_suppression("Failed to setup PRIMARY index of ndb_sql_metadata");
27 call mtr.add_suppression("stored grants: not initialized.");
28 call mtr.add_suppression("stored grants: failed to apply stored grants.");
29 --enable_query_log
30
31 connection default;
32
33 # Create view which displays all NDB objects type and name.
34 --disable_query_log ONCE
35 CREATE VIEW ndb_objects AS
36 SELECT
37 t.type_name as type,
38 /* Return everything after last slash as name */
39 SUBSTRING_INDEX(i.fq_name, "/", -1) AS name
40 FROM ndbinfo.dict_obj_info AS i
41 JOIN ndbinfo.dict_obj_types AS t ON i.type = t.type_id;
42
43 let $qry =
44 select type,name from ndb_objects
45 where (type like '%Index%' or type like '%Foreign key def%')
46 and (name like '%t1%' or name like '%t2%')
47 order by name;
48
49 let $cre1 =
50 create table t1 (
51 a int not null,
52 b int not null,
53 unique key t1x1 (b) using hash,
54 primary key using hash (a)
55 ) engine=ndb;
56
57 let $cre2 =
58 create table t2 (
59 a int not null,
60 b int not null,
61 key t2x1 (b),
62 primary key using hash (a),
63 constraint t2fk1 foreign key (b) references t1 (b)
64 ) engine=ndb;
65
66 --eval $cre1
67 --eval $cre2
68
69 --echo Expect fk and indexes to exist
70 --disable_query_log ONCE
71 --eval $qry
72
73 insert into t1 values (1,10),(2,20),(3,30),(4,40),(5,50);
74 insert into t2 values (1,10),(2,10),(3,30),(4,50),(5,50);
75
76 select * from t1 where b = 10 order by a;
77 select * from t2 where b = 10 order by a;
78
79 --echo # run restart skip indexes
80
81 --exec $NDB_MGM -e "all restart -n" >> $NDB_TOOLS_OUTPUT
82 --exec $NDB_WAITER --not-started
83 --exec $NDB_MGM -e "all start" >> $NDB_TOOLS_OUTPUT
84 --exec $NDB_WAITER
85
86 # Wait for MySQL Server reconnect after cluster restart
87 --source include/ndb_not_readonly.inc
88
89 --echo Expect neither fk or indexes since restart was without indexes
90 --disable_query_log ONCE
91 --eval $qry
92
93 # FRM is wrong so SQL level fails (drop works)
94 # verify that SQL level can be fixed via BACKUP
95
96 --echo # run backup
97 --source include/ndb_backup.inc
98
99 --echo # create empty schema
100 drop table t2, t1;
101 --eval $cre1
102 --eval $cre2
103
104 --echo Expect fk and indexes to exist again
105 --disable_query_log ONCE
106 --eval $qry
107
108 --echo # run restore
109 --exec $NDB_RESTORE -b $the_backup_id -n 1 -r $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT
110 --exec $NDB_RESTORE -b $the_backup_id -n 2 -r $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT
111
112 select * from t1 where b = 10 order by a;
113 select * from t2 where b = 10 order by a;
114
115 drop table t2, t1;
116 --source suite/ndb/include/backup_restore_cleanup.inc
117 --remove_file $NDB_TOOLS_OUTPUT
118
119 --disable_query_log ONCE
120 DROP VIEW ndb_objects;