Debian Codegraph @

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

raw
1 ################################################################################
2 # Test new option --with-apply-status with ndb_restore to restore from log files
3 ################################################################################
4
5 -- source include/have_multi_ndb.inc
6 -- source suite/ndb/include/backup_restore_setup.inc
7 -- source suite/ndb/t/have_ndb_error_insert.inc
8
9 CREATE TABLE t1 (
10 id int,
11 name varchar(255),
12 age int,
13 PRIMARY KEY(id)
14 ) engine=ndbcluster;
15
16 INSERT INTO test.t1 VALUES
17 (1, 'p1', 19), (2, 'p0', 11), (3, 'p2', 43),
18 (4, 'p3', 99), (5, 'p4', 33), (6, 'p5', 45);
19
20 INSERT INTO mysql.ndb_apply_status VALUES
21 (1,12,_binary 'position',123,1234), (2,12,_binary 'position',123,1234),
22 (3,12,_binary 'position',123,1234), (4,12,_binary 'position',123,1234),
23 (5,12,_binary 'position',123,1234), (6,12,_binary 'position',123,1234),
24 (7,12,_binary 'position',123,1234), (8,12,_binary 'position',123,1234),
25 (9,12,_binary 'position',123,1234), (10,12,_binary 'position',123,1234);
26
27 #Introduce error to ensure that backup halts
28 --exec $NDB_MGM -e "ALL ERROR 10039" >> $NDB_TOOLS_OUTPUT
29
30 --echo Run backup snapshotend
31 --source suite/ndb/t/ndb_backup_nowait_start.inc
32
33 --echo Make a set of changes which we expect to be logged
34
35 --echo 4 new rows
36 INSERT INTO mysql.ndb_apply_status VALUES
37 (11,12,_binary 'position',123,1234), (12,12,_binary 'position',123,1234),
38 (13,12,_binary 'position',123,1234), (14,12,_binary 'position',123,1234);
39
40 #Remove error previously introduced
41 --exec $NDB_MGM -e "ALL ERROR 0" >> $NDB_TOOLS_OUTPUT
42
43 # Wait backup completed
44 --source suite/ndb/t/ndb_backup_nowait_wait.inc
45
46 --echo 4 new rows after backup is completed
47 INSERT INTO mysql.ndb_apply_status VALUES
48 (15,12,_binary 'position',123,1234), (16,12,_binary 'position',123,1234),
49 (17,12,_binary 'position',123,1234), (18,12,_binary 'position',123,1234);
50
51 DROP TABLE test.t1;
52 DELETE FROM mysql.ndb_apply_status;
53
54 -- echo # Use case #1: Restore epoch along with replication status
55 -- exec $NDB_RESTORE --show-part-id -b $the_backup_id -n 1 --restore-meta --print_meta --disable-indexes $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT
56 -- exec $NDB_RESTORE --show-part-id -b $the_backup_id -n 1 --restore-data --with-apply-status --print-sql-log $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT
57 -- exec $NDB_RESTORE --show-part-id -b $the_backup_id -n 2 --restore-data --with-apply-status --print-sql-log $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT
58 -- exec $NDB_RESTORE --show-part-id -b $the_backup_id -n 2 --restore-epoch --rebuild-indexes $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT
59
60 SELECT COUNT(*) FROM test.t1;
61 -- echo # 14 rows will be restored to ndb_apply_status and another row will be generated with server_id = 0
62 SELECT server_id FROM mysql.ndb_apply_status ORDER BY server_id;
63
64 -- echo # cleanup
65 TRUNCATE test.t1;
66 DELETE FROM mysql.ndb_apply_status;
67
68
69 INSERT INTO test.t1 VALUES
70 (1, 'p1', 19), (2, 'p0', 11), (3, 'p2', 43),
71 (4, 'p3', 99), (5, 'p4', 33), (6, 'p5', 45);
72
73 INSERT INTO mysql.ndb_apply_status VALUES
74 (1,12,_binary 'position',123,1234), (2,12,_binary 'position',123,1234),
75 (3,12,_binary 'position',123,1234), (4,12,_binary 'position',123,1234),
76 (5,12,_binary 'position',123,1234), (6,12,_binary 'position',123,1234),
77 (7,12,_binary 'position',123,1234), (8,12,_binary 'position',123,1234),
78 (9,12,_binary 'position',123,1234), (10,12,_binary 'position',123,1234);
79
80 #Introduce error to ensure that backup halts
81 --exec $NDB_MGM -e "ALL ERROR 10039" >> $NDB_TOOLS_OUTPUT
82
83 --echo Run backup snapshotstart
84 let $start_backup_extra = SNAPSHOTSTART;
85 --source suite/ndb/t/ndb_backup_nowait_start.inc
86
87 --echo Make a set of changes which we expect to be logged
88
89 --echo 4 new rows
90
91 INSERT INTO test.t1 VALUES
92 (7, 'p1', 19), (8, 'p0', 11),
93 (9, 'p2', 43), (10, 'p0', 11);
94
95 INSERT INTO mysql.ndb_apply_status VALUES
96 (11,12,_binary 'position',123,1234), (12,12,_binary 'position',123,1234),
97 (13,12,_binary 'position',123,1234), (14,12,_binary 'position',123,1234);
98
99 #Remove error previously introduced
100 --exec $NDB_MGM -e "ALL ERROR 0" >> $NDB_TOOLS_OUTPUT
101
102 # Wait backup completed
103 --source suite/ndb/t/ndb_backup_nowait_wait.inc
104
105 --echo 4 new rows after backup is completed
106 INSERT INTO mysql.ndb_apply_status VALUES
107 (15,12,_binary 'position',123,1234), (16,12,_binary 'position',123,1234),
108 (17,12,_binary 'position',123,1234), (18,12,_binary 'position',123,1234);
109
110 DROP TABLE test.t1;
111 DELETE FROM mysql.ndb_apply_status;
112
113 -- echo # Use case #2: Restore epoch along with replication status
114 -- exec $NDB_RESTORE --show-part-id -b $the_backup_id -n 1 --restore-meta --print_meta --disable-indexes $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT
115 -- exec $NDB_RESTORE --show-part-id -b $the_backup_id -n 1 --restore-data --with-apply-status --print-sql-log $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT
116 -- exec $NDB_RESTORE --show-part-id -b $the_backup_id -n 2 --restore-data --with-apply-status --print-sql-log $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT
117 -- exec $NDB_RESTORE --show-part-id -b $the_backup_id -n 2 --restore-epoch --rebuild-indexes $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT
118
119 SELECT COUNT(*) FROM test.t1;
120 -- echo # 10 rows will be restored to ndb_apply_status and another row will be generated with server_id = 0
121 SELECT server_id FROM mysql.ndb_apply_status ORDER BY server_id;
122
123 -- echo # cleanup
124 DROP TABLE test.t1;
125 DELETE FROM mysql.ndb_apply_status;
126
127 --source suite/ndb/include/backup_restore_cleanup.inc
128 --remove_file $NDB_TOOLS_OUTPUT