| 1 |
###################################################################### |
| 2 |
# Test new option --with-apply-status with ndb_restore |
| 3 |
###################################################################### |
| 4 |
|
| 5 |
-- source include/have_multi_ndb.inc |
| 6 |
-- source suite/ndb/include/backup_restore_setup.inc |
| 7 |
|
| 8 |
CREATE TABLE t1 ( |
| 9 |
id INT, |
| 10 |
col INT |
| 11 |
) ENGINE=ndbcluster; |
| 12 |
|
| 13 |
INSERT INTO test.t1 VALUES |
| 14 |
(7,7),(8,8),(6,6),(1,1),(4,4),(5,5),(8,8),(2,2),(9,9),(6,6),(3,3),(7,7), |
| 15 |
(1,1),(4,4),(6,6),(8,8),(1,1),(5,5),(3,3),(1,1),(4,4),(9,9),(3,3),(5,5); |
| 16 |
|
| 17 |
INSERT INTO mysql.ndb_apply_status VALUES |
| 18 |
(1,12,_binary 'logname',123,1234), (2,12,_binary 'logname',123,1234), |
| 19 |
(3,12,_binary 'logname',123,1234), (4,12,_binary 'logname',123,1234), |
| 20 |
(5,12,_binary 'logname',123,1234), (6,12,_binary 'logname',123,1234), |
| 21 |
(7,12,_binary 'logname',123,1234), (8,12,_binary 'logname',123,1234), |
| 22 |
(9,12,_binary 'logname',123,1234), (10,12,_binary 'logname',123,1234); |
| 23 |
|
| 24 |
-- echo # Take backup and drop the tables |
| 25 |
-- source include/ndb_backup.inc |
| 26 |
DROP TABLE test.t1; |
| 27 |
DELETE FROM mysql.ndb_apply_status; |
| 28 |
|
| 29 |
-- echo # Use case #1: Restore epoch along with replication status |
| 30 |
-- 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 |
| 31 |
-- exec $NDB_RESTORE --show-part-id -b $the_backup_id -n 1 --restore-data --with-apply-status $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 32 |
-- exec $NDB_RESTORE --show-part-id -b $the_backup_id -n 2 --restore-data --with-apply-status --restore-epoch $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 33 |
-- exec $NDB_RESTORE --show-part-id -b $the_backup_id -n 2 --rebuild-indexes $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 34 |
|
| 35 |
SELECT COUNT(*) FROM test.t1; |
| 36 |
-- echo # 10 rows will be restored to ndb_apply_status and another row will be generated with server_id = 0 |
| 37 |
SELECT COUNT(*) FROM mysql.ndb_apply_status; |
| 38 |
SELECT COUNT(*) FROM mysql.ndb_apply_status WHERE server_id=0; |
| 39 |
|
| 40 |
-- echo # Drop the tables to restore them again with a different use case |
| 41 |
DROP TABLE test.t1; |
| 42 |
DELETE FROM mysql.ndb_apply_status; |
| 43 |
|
| 44 |
-- echo # Use case #2: Restore epoch after replication status is restored with data restore |
| 45 |
-- 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 |
| 46 |
-- exec $NDB_RESTORE --show-part-id -b $the_backup_id -n 1 --restore-data --with-apply-status $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 47 |
-- exec $NDB_RESTORE --show-part-id -b $the_backup_id -n 2 --restore-data --with-apply-status $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 48 |
-- exec $NDB_RESTORE --show-part-id -b $the_backup_id -n 2 --restore-epoch --rebuild-indexes $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 49 |
|
| 50 |
SELECT COUNT(*) FROM test.t1; |
| 51 |
SELECT COUNT(*) FROM mysql.ndb_apply_status; |
| 52 |
|
| 53 |
-- echo # Drop the tables to restore them again with a different use case |
| 54 |
DROP TABLE test.t1; |
| 55 |
DELETE FROM mysql.ndb_apply_status; |
| 56 |
|
| 57 |
-- echo # Use case #3: Restore replication status without epoch with server_id = 0 |
| 58 |
-- 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 |
| 59 |
-- exec $NDB_RESTORE --show-part-id -b $the_backup_id -n 1 --restore-data --with-apply-status $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 60 |
-- exec $NDB_RESTORE --show-part-id -b $the_backup_id -n 2 --restore-data --with-apply-status $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 61 |
-- exec $NDB_RESTORE --show-part-id -b $the_backup_id -n 2 --rebuild-indexes $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 62 |
|
| 63 |
SELECT COUNT(*) FROM test.t1; |
| 64 |
-- echo # Only 10 rows will be restored to ndb_apply_status |
| 65 |
SELECT * FROM mysql.ndb_apply_status ORDER BY server_id; |
| 66 |
|
| 67 |
-- echo # Drop the tables to restore them again with a different use case |
| 68 |
DROP TABLE test.t1; |
| 69 |
DELETE FROM mysql.ndb_apply_status; |
| 70 |
|
| 71 |
-- echo # Use case #4: Attempt to restore replication status without restore-data/print-data/print-log/print-sql-log |
| 72 |
-- 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 |
| 73 |
-- error 2 |
| 74 |
-- exec $NDB_RESTORE --show-part-id -b $the_backup_id -n 1 --restore-epoch --with-apply-status $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 75 |
|
| 76 |
-- echo # Drop the tables to restore them again with a different use case |
| 77 |
DROP TABLE test.t1; |
| 78 |
DELETE FROM mysql.ndb_apply_status; |
| 79 |
|
| 80 |
-- echo # Use case #5: Restore appropriate replication status when the backup already contains a row with server_id=0 |
| 81 |
INSERT INTO mysql.ndb_apply_status VALUES (0,12,_binary 'logname',0,0), |
| 82 |
(1,12,_binary 'logname',123,1234), (2,12,_binary 'logname',123,1234), |
| 83 |
(3,12,_binary 'logname',123,1234), (4,12,_binary 'logname',123,1234), |
| 84 |
(5,12,_binary 'logname',123,1234), (6,12,_binary 'logname',123,1234), |
| 85 |
(7,12,_binary 'logname',123,1234), (8,12,_binary 'logname',123,1234), |
| 86 |
(9,12,_binary 'logname',123,1234), (10,12,_binary 'logname',123,1234); |
| 87 |
|
| 88 |
-- echo # Take backup and drop the tables |
| 89 |
-- source include/ndb_backup.inc |
| 90 |
DELETE FROM mysql.ndb_apply_status; |
| 91 |
|
| 92 |
-- 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 |
| 93 |
-- exec $NDB_RESTORE --show-part-id -b $the_backup_id -n 1 --restore-data --with-apply-status $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 94 |
-- exec $NDB_RESTORE --show-part-id -b $the_backup_id -n 2 --restore-data --with-apply-status $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 95 |
-- exec $NDB_RESTORE --show-part-id -b $the_backup_id -n 2 --restore-epoch --rebuild-indexes $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 96 |
|
| 97 |
SELECT COUNT(*) FROM mysql.ndb_apply_status WHERE server_id = 0; |
| 98 |
|
| 99 |
-- echo # Truncate the table to restore again with a different use case |
| 100 |
DELETE FROM mysql.ndb_apply_status; |
| 101 |
|
| 102 |
-- echo # Use case #5: Restore appropriate replication status when the backup already contains a row with server_id=0 without --restore-epoch |
| 103 |
-- 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 |
| 104 |
-- exec $NDB_RESTORE --show-part-id -b $the_backup_id -n 1 --restore-data --with-apply-status $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 105 |
-- exec $NDB_RESTORE --show-part-id -b $the_backup_id -n 2 --restore-data --with-apply-status $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 106 |
-- exec $NDB_RESTORE --show-part-id -b $the_backup_id -n 2 --rebuild-indexes $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 107 |
|
| 108 |
SELECT * FROM mysql.ndb_apply_status ORDER BY server_id; |
| 109 |
|
| 110 |
-- echo # cleanup |
| 111 |
DELETE FROM mysql.ndb_apply_status; |
| 112 |
|
| 113 |
--source suite/ndb/include/backup_restore_cleanup.inc |
| 114 |
--remove_file $NDB_TOOLS_OUTPUT |