Debian Codegraph @

mysql-test/suite/ndb/t/ndb_backup_restore.inc

raw
1 --source include/have_ndb.inc
2
3 --echo "Create tables for backup"
4 --disable_query_log
5 use test;
6
7 create table t0(id int primary key, val int) engine=ndb;
8 create table t1(val int) engine=ndb;
9 create table t2(id int primary key) engine=ndb;
10 create table t3(id int primary key auto_increment, val int) engine=ndb;
11 create table t4(id int primary key, val int default 11001) engine=ndb;
12 create table t5(id int primary key, val text) engine=ndb;
13 create table t6(id int primary key, val int unique) engine=ndb;
14 create table t7(id int auto_increment, val1 int, val2 int, primary key(id,val1)) engine=ndb;
15 create table t8(id int primary key, val varbinary(29990)) engine=ndb;
16 create table t9(
17 auto int(5) unsigned NOT NULL auto_increment,
18 string char(10) default "hello",
19 vstring varchar(10) default "hello",
20 tiny tinyint(4) DEFAULT '0' NOT NULL ,
21 short smallint(6) DEFAULT '1' NOT NULL ,
22 medium mediumint(8) DEFAULT '0' NOT NULL,
23 long_int int(11) DEFAULT '0' NOT NULL,
24 longlong bigint(13) DEFAULT '0' NOT NULL,
25 real_float float(13,1) DEFAULT 0.0 NOT NULL,
26 real_double double(16,4),
27 real_decimal decimal(16,4),
28 utiny tinyint(3) unsigned DEFAULT '0' NOT NULL,
29 ushort smallint(5) unsigned zerofill DEFAULT '00000' NOT NULL,
30 umedium mediumint(8) unsigned DEFAULT '0' NOT NULL,
31 ulong int(11) unsigned DEFAULT '0' NOT NULL,
32 ulonglong bigint(13) unsigned DEFAULT '0' NOT NULL,
33 bits bit(3),
34 options enum('one','two','three') not null,
35 flags set('one','two','three') not null,
36 date_field date,
37 year_field year,
38 time_field time,
39 date_time datetime,
40 PRIMARY KEY (auto),
41 KEY (utiny),
42 KEY (tiny),
43 KEY (short),
44 KEY any_name (medium),
45 KEY (longlong),
46 KEY (real_float),
47 KEY (ushort),
48 KEY (umedium),
49 KEY (ulong),
50 KEY (ulonglong,ulong),
51 KEY (options,flags)
52 )engine=ndb;
53
54 let $i=9;
55 # insert 9 rows
56 while ($i)
57 {
58 eval insert into t0 values($i,$i);
59 eval insert into t1 values($i);
60 eval insert into t2 values($i);
61 eval insert into t3(val) values($i);
62 eval insert into t4(id) values($i);
63 eval insert into t5 values($i,REPEAT('$i', 4000));
64 eval insert into t6 values($i,$i);
65 eval insert into t7(val1,val2) values($i,$i);
66 eval insert into t8 values($i,REPEAT('$i',29000));
67 eval insert into t9 (string,vstring,tiny,short,medium,long_int,longlong,
68 real_float,real_double, real_decimal,utiny, ushort, umedium,ulong,ulonglong,
69 bits,options,flags,date_field,year_field,time_field,date_time)
70 values
71 ("$i$i$i$i","$i$i$i$i",-$i,-$i,-$i,-$i,-$i,$i.$i,$i.$i,$i.$i,$i,$i,$i,$i,$i,
72 b'001','one','one', '19$i$i-$i-$i','19$i$i','$i:$i:$i','19$i$i-$i-$i $i:$i:$i');
73 dec $i;
74 }
75 # insert rows with NULL values
76 eval insert into t0 values(10,NULL);
77 eval insert into t1 values(NULL);
78 eval insert into t2 values(10);
79 eval insert into t3(val) values(NULL);
80 eval insert into t4(id) values(10);
81 eval insert into t5 values(10,NULL);
82 eval insert into t6 values(10,NULL);
83 eval insert into t7(val1,val2) values(10,NULL);
84 eval insert into t8 values(10,NULL);
85 eval insert into t9 (string,vstring,tiny,short,medium,long_int,longlong,
86 real_float,real_double, real_decimal,utiny,ushort,umedium,ulong,ulonglong,
87 bits,options,flags,date_field,year_field,time_field,date_time)
88 values
89 (NULL,NULL,10,10,10,10,10,10.1,NULL,NULL,10,10,10,10,10,
90 NULL,'two','two',NULL,NULL,NULL,NULL);
91
92 --exec $NDB_MGM -e "all error 10039"
93
94 if ($snapshotstart)
95 {
96 let $start_backup_extra = SNAPSHOTSTART;
97 }
98 --source suite/ndb/t/ndb_backup_nowait_start.inc
99
100 --echo "Update tables during backup"
101 --disable_query_log
102 use test;
103 update t0 set val = 12345 where val is null;
104 update t1 set val = 11 where val = 1;
105 update t2 set id = 22 where id = 2;
106 update t3 set val = 33 where id = 3;
107 update t4 set val = 44 where id = 4;
108 update t5 set val = REPEAT("123 $#",1000) where id = 5;
109 update t6 set val = 66 where id = 6;
110 update t7 set val1 = 77 where id = 7;
111 update t8 set val = REPEAT("8", 29900) where id = 8;
112 update t9 set string="bbbb",vstring="bbbb",tiny=-22,short=-22,medium=-22,
113 long_int=-22,longlong=-22,real_float=22.22,real_double=22.22,real_decimal=22.22,
114 utiny=22,ushort=22,umedium=22,ulong=22,ulonglong=22, bits=b'010',
115 options='two',flags='two', date_field='1922-02-22',year_field='1922',
116 time_field='22:22:22',date_time='1922-02-22 22:22:22' where auto=1;
117 --enable_query_log
118
119 --exec $NDB_MGM -e "all error 0"
120
121 --echo "Wait for backup to complete"
122 --source suite/ndb/t/ndb_backup_nowait_wait.inc
123
124 --echo "Drop tables after backup completes"
125 --disable_query_log
126 use test;
127 drop table t0;
128 drop table t1;
129 drop table t2;
130 drop table t3;
131 drop table t4;
132 drop table t5;
133 drop table t6;
134 drop table t7;
135 drop table t8;
136 drop table t9;
137 --enable_query_log
138
139 --source include/ndb_backup_id.inc
140
141 if (!$serialrestore)
142 {
143 --echo "Restoring metadata"
144 --exec $NDB_RESTORE -b $the_backup_id -n 1 -m $NDB_BACKUPS-$the_backup_id/ >> $NDB_TOOLS_OUTPUT 2>&1
145
146 --echo "Restoring backup on node 1"
147 --exec $NDB_RESTORE -b $the_backup_id -n 1 -r $NDB_BACKUPS-$the_backup_id/ >> $NDB_TOOLS_OUTPUT 2>&1
148
149 --echo "Restoring backup on node 2"
150 --exec $NDB_RESTORE -b $the_backup_id -n 2 -r $NDB_BACKUPS-$the_backup_id/ >> $NDB_TOOLS_OUTPUT 2>&1
151 }
152 if ($serialrestore)
153 {
154 --echo "Restoring metadata"
155 --exec $NDB_RESTORE -b $the_backup_id -n 1 -m $NDB_BACKUPS-$the_backup_id/BACKUP-$the_backup_id-PART-1-OF-$backup_parts >> $NDB_TOOLS_OUTPUT 2>&1
156
157 --echo "Restoring multithreaded backup parts serially on node 1"
158 let $current_part = $backup_parts;
159 while ($current_part)
160 {
161 --exec $NDB_RESTORE -b $the_backup_id -n 1 -r $NDB_BACKUPS-$the_backup_id/BACKUP-$the_backup_id-PART-$current_part-OF-$backup_parts >> $NDB_TOOLS_OUTPUT 2>&1
162 dec $current_part;
163 }
164
165 --echo "Restoring multithreaded backup parts serially on node 2"
166 let $current_part = $backup_parts;
167 while ($current_part)
168 {
169 --exec $NDB_RESTORE -b $the_backup_id -n 2 -r $NDB_BACKUPS-$the_backup_id/BACKUP-$the_backup_id-PART-$current_part-OF-$backup_parts >> $NDB_TOOLS_OUTPUT 2>&1
170 dec $current_part;
171 }
172 }
173 --echo "Print restored rows"
174 use test;
175 select * from t0 order by id;
176 select * from t1 order by val;
177 select * from t2 order by id;
178 select * from t3 order by id;
179 select * from t4 order by id;
180 select id, sha1(val) from t5 order by id;
181 select * from t6 order by id;
182 select * from t7 order by id;
183 select id, sha1(val) from t8 order by id;
184 select * from t9 order by auto;
185
186 --echo "Drop tables after backup completes"
187 --disable_query_log
188 use test;
189 drop table t0;
190 drop table t1;
191 drop table t2;
192 drop table t3;
193 drop table t4;
194 drop table t5;
195 drop table t6;
196 drop table t7;
197 drop table t8;
198 drop table t9;
199 --enable_query_log