Debian Codegraph @

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

raw
1 --source include/have_ndb.inc
2 --source include/have_ndb_debug.inc
3 -- source suite/ndb/include/backup_restore_setup.inc
4
5 --disable_query_log
6 set @old_ndb_autoincrement_prefetch_sz = @@session.ndb_autoincrement_prefetch_sz;
7 set ndb_autoincrement_prefetch_sz = 1;
8 --enable_query_log
9
10 --echo Check some behaviours around restoring autoinc
11 --echo tables where autoinc values are used in the log
12
13 use test;
14
15 create table signed (a int auto_increment primary key, b int) engine=ndb;
16 create table test.t1 (a int auto_increment primary key, b int) engine=ndb;
17 create table test.t2 (a int auto_increment primary key, b int) engine=ndb;
18
19 # Create some default auto inc entries
20 insert into signed (b) values (1), (2), (3);
21 # Add a negative entry
22 insert into signed (a,b) values (-20, -20);
23
24 insert into test.t1 (b) values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
25 insert into test.t2 (b) values (1), (2);
26
27 --echo Cause backup stall
28 --exec $NDB_MGM -e "all error 10039" >> $NDB_TOOLS_OUTPUT
29
30 --source suite/ndb/t/ndb_backup_nowait_start.inc
31
32 # Add some more default entries and a negative entry, which
33 # will be in the backup log.
34 insert into signed (b) values (4), (5), (6), (7);
35 insert into signed (a,b) values (-30, -30);
36
37 insert into test.t1 (b) values (11), (12), (13), (14), (15), (16), (17), (18), (19), (20);
38 insert into test.t2 (b) values (3), (4);
39
40 select auto_increment from information_schema.tables where table_schema='test' and table_name='signed';
41 select auto_increment from information_schema.tables where table_schema='test' and table_name='t1';
42 select auto_increment from information_schema.tables where table_schema='test' and table_name='t2';
43
44 --exec $NDB_MGM -e "all error 0" >> $NDB_TOOLS_OUTPUT
45 --source suite/ndb/t/ndb_backup_nowait_wait.inc
46
47 drop table signed;
48 drop table test.t1;
49 drop table test.t2;
50
51 create table signed (a int auto_increment primary key, b int) engine=ndb;
52
53 --echo Recreate tables in opposite order so they swap table ids
54
55 create table test.t2 (a int auto_increment primary key, b int) engine=ndb;
56 create table test.t1 (a int auto_increment primary key, b int) engine=ndb;
57
58 --echo Restore data in order 1,2
59 --echo Node 1
60 --exec $NDB_RESTORE -b $the_backup_id -n 1 -r $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT
61 --echo Node 2
62 --exec $NDB_RESTORE -b $the_backup_id -n 2 -r $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT
63
64 --echo Check restored auto-inc metadata :
65 select auto_increment from information_schema.tables where table_schema='test' and table_name='signed';
66 select auto_increment from information_schema.tables where table_schema='test' and table_name='t1';
67 select auto_increment from information_schema.tables where table_schema='test' and table_name='t2';
68
69 drop table signed;
70 drop table test.t1;
71 drop table test.t2;
72
73 create table signed (a int auto_increment primary key, b int) engine=ndb;
74
75 --echo Recreate tables in opposite order so they swap table ids
76
77 create table test.t2 (a int auto_increment primary key, b int) engine=ndb;
78 create table test.t1 (a int auto_increment primary key, b int) engine=ndb;
79
80 --echo Restore data in order 2,1
81 --echo Node 2
82 --exec $NDB_RESTORE -b $the_backup_id -n 2 -r $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT
83 --echo Node 1
84 --exec $NDB_RESTORE -b $the_backup_id -n 1 -r $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT
85
86 --echo Check restored auto-inc metadata :
87 select auto_increment from information_schema.tables where table_schema='test' and table_name='signed';
88 select auto_increment from information_schema.tables where table_schema='test' and table_name='t1';
89 select auto_increment from information_schema.tables where table_schema='test' and table_name='t2';
90
91 drop table signed;
92 drop table test.t1;
93 drop table test.t2;
94
95 --source suite/ndb/include/backup_restore_cleanup.inc
96 --remove_file $NDB_TOOLS_OUTPUT
97
98 --disable_query_log
99 set ndb_autoincrement_prefetch_sz = @old_ndb_autoincrement_prefetch_sz;
100 --enable_query_log