###################################################################### # Test new option --with-apply-status with ndb_restore ###################################################################### -- source include/have_multi_ndb.inc -- source suite/ndb/include/backup_restore_setup.inc CREATE TABLE t1 ( id INT, col INT ) ENGINE=ndbcluster; INSERT INTO test.t1 VALUES (7,7),(8,8),(6,6),(1,1),(4,4),(5,5),(8,8),(2,2),(9,9),(6,6),(3,3),(7,7), (1,1),(4,4),(6,6),(8,8),(1,1),(5,5),(3,3),(1,1),(4,4),(9,9),(3,3),(5,5); INSERT INTO mysql.ndb_apply_status VALUES (1,12,_binary 'logname',123,1234), (2,12,_binary 'logname',123,1234), (3,12,_binary 'logname',123,1234), (4,12,_binary 'logname',123,1234), (5,12,_binary 'logname',123,1234), (6,12,_binary 'logname',123,1234), (7,12,_binary 'logname',123,1234), (8,12,_binary 'logname',123,1234), (9,12,_binary 'logname',123,1234), (10,12,_binary 'logname',123,1234); -- echo # Take backup and drop the tables -- source include/ndb_backup.inc DROP TABLE test.t1; DELETE FROM mysql.ndb_apply_status; -- echo # Use case #1: Restore epoch along with replication status -- 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 -- 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 -- 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 -- exec $NDB_RESTORE --show-part-id -b $the_backup_id -n 2 --rebuild-indexes $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT SELECT COUNT(*) FROM test.t1; -- echo # 10 rows will be restored to ndb_apply_status and another row will be generated with server_id = 0 SELECT COUNT(*) FROM mysql.ndb_apply_status; SELECT COUNT(*) FROM mysql.ndb_apply_status WHERE server_id=0; -- echo # Drop the tables to restore them again with a different use case DROP TABLE test.t1; DELETE FROM mysql.ndb_apply_status; -- echo # Use case #2: Restore epoch after replication status is restored with data restore -- 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 -- 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 -- 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 -- exec $NDB_RESTORE --show-part-id -b $the_backup_id -n 2 --restore-epoch --rebuild-indexes $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT SELECT COUNT(*) FROM test.t1; SELECT COUNT(*) FROM mysql.ndb_apply_status; -- echo # Drop the tables to restore them again with a different use case DROP TABLE test.t1; DELETE FROM mysql.ndb_apply_status; -- echo # Use case #3: Restore replication status without epoch with server_id = 0 -- 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 -- 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 -- 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 -- exec $NDB_RESTORE --show-part-id -b $the_backup_id -n 2 --rebuild-indexes $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT SELECT COUNT(*) FROM test.t1; -- echo # Only 10 rows will be restored to ndb_apply_status SELECT * FROM mysql.ndb_apply_status ORDER BY server_id; -- echo # Drop the tables to restore them again with a different use case DROP TABLE test.t1; DELETE FROM mysql.ndb_apply_status; -- echo # Use case #4: Attempt to restore replication status without restore-data/print-data/print-log/print-sql-log -- 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 -- error 2 -- 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 -- echo # Drop the tables to restore them again with a different use case DROP TABLE test.t1; DELETE FROM mysql.ndb_apply_status; -- echo # Use case #5: Restore appropriate replication status when the backup already contains a row with server_id=0 INSERT INTO mysql.ndb_apply_status VALUES (0,12,_binary 'logname',0,0), (1,12,_binary 'logname',123,1234), (2,12,_binary 'logname',123,1234), (3,12,_binary 'logname',123,1234), (4,12,_binary 'logname',123,1234), (5,12,_binary 'logname',123,1234), (6,12,_binary 'logname',123,1234), (7,12,_binary 'logname',123,1234), (8,12,_binary 'logname',123,1234), (9,12,_binary 'logname',123,1234), (10,12,_binary 'logname',123,1234); -- echo # Take backup and drop the tables -- source include/ndb_backup.inc DELETE FROM mysql.ndb_apply_status; -- 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 -- 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 -- 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 -- exec $NDB_RESTORE --show-part-id -b $the_backup_id -n 2 --restore-epoch --rebuild-indexes $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT SELECT COUNT(*) FROM mysql.ndb_apply_status WHERE server_id = 0; -- echo # Truncate the table to restore again with a different use case DELETE FROM mysql.ndb_apply_status; -- echo # Use case #5: Restore appropriate replication status when the backup already contains a row with server_id=0 without --restore-epoch -- 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 -- 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 -- 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 -- exec $NDB_RESTORE --show-part-id -b $the_backup_id -n 2 --rebuild-indexes $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT SELECT * FROM mysql.ndb_apply_status ORDER BY server_id; -- echo # cleanup DELETE FROM mysql.ndb_apply_status; --source suite/ndb/include/backup_restore_cleanup.inc --remove_file $NDB_TOOLS_OUTPUT