| 1 |
--source include/have_ndb.inc |
| 2 |
--source suite/ndb/include/backup_restore_setup.inc |
| 3 |
|
| 4 |
# |
| 5 |
# Check that tables restored with the --disable-indexes option are |
| 6 |
# not automatically synchronized. Synchronization of such tables |
| 7 |
# would lead to the wrong table definition being installed in the DD |
| 8 |
# and would render the table unusable until the indexes were restored |
| 9 |
# to NDB |
| 10 |
# |
| 11 |
|
| 12 |
# Create tables with various indexes |
| 13 |
CREATE TABLE t1 ( |
| 14 |
a INT PRIMARY KEY, |
| 15 |
b INT NOT NULL, |
| 16 |
c INT NOT NULL, |
| 17 |
UNIQUE ib(b), |
| 18 |
INDEX ic(c) |
| 19 |
) ENGINE NDB; |
| 20 |
|
| 21 |
INSERT INTO t1 VALUES (1,2,3),(2,3,5),(3,4,6),(4,5,8),(5,6,2),(6,7,2); |
| 22 |
|
| 23 |
CREATE TABLE parent ( |
| 24 |
c1 INT PRIMARY KEY |
| 25 |
) ENGINE NDB; |
| 26 |
|
| 27 |
INSERT INTO parent VALUES (1),(2); |
| 28 |
|
| 29 |
CREATE TABLE child ( |
| 30 |
c1 INT PRIMARY KEY, |
| 31 |
c2 INT, |
| 32 |
INDEX xc2(c2), |
| 33 |
FOREIGN KEY(c2) |
| 34 |
REFERENCES parent(c1) |
| 35 |
ON DELETE CASCADE |
| 36 |
) ENGINE NDB; |
| 37 |
|
| 38 |
INSERT INTO child VALUES (1,1),(2,2); |
| 39 |
|
| 40 |
# Take a backup |
| 41 |
--source include/ndb_backup.inc |
| 42 |
|
| 43 |
DROP TABLE t1,child,parent; |
| 44 |
|
| 45 |
# Store initial counts of both detected and synchronized objects |
| 46 |
--let $initial_detected_count = query_get_value(SHOW STATUS LIKE 'Ndb_metadata_detected_count', Value, 1) |
| 47 |
--let $initial_synced_count = query_get_value(SHOW STATUS LIKE 'Ndb_metadata_synced_count', Value, 1) |
| 48 |
|
| 49 |
--echo Restore with --disable-indexes |
| 50 |
--exec $NDB_RESTORE -b $the_backup_id -n 1 -m -r --disable-indexes $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 51 |
--exec $NDB_RESTORE -b $the_backup_id -n 2 -r $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 52 |
|
| 53 |
--disable_query_log |
| 54 |
# Suppress expected warnings due to missing indexes |
| 55 |
CALL mtr.add_suppression("Metadata check has failed"); |
| 56 |
CALL mtr.add_suppression("The NDB Dictionary table definition is not identical"); |
| 57 |
CALL mtr.add_suppression("Diff in 'index_count'"); |
| 58 |
# Set low interval so changes are detected quickly |
| 59 |
SET @old_ndb_metadata_check = @@global.ndb_metadata_check; |
| 60 |
SET @old_ndb_metadata_check_interval = @@global.ndb_metadata_check_interval; |
| 61 |
SET GLOBAL ndb_metadata_check = true; |
| 62 |
SET GLOBAL ndb_metadata_check_interval = 5; |
| 63 |
--enable_query_log |
| 64 |
|
| 65 |
# Wait until the following 3 object changes are detected: |
| 66 |
# Table 'test.t1' |
| 67 |
# Table 'test.child' |
| 68 |
# Table 'test.parent' |
| 69 |
--let $expected_changes = 3 |
| 70 |
--let $max_wait = 30 |
| 71 |
--source wait_metadata_changes_detected.inc |
| 72 |
|
| 73 |
--disable_query_log |
| 74 |
# Changes have been detected, reset values |
| 75 |
SET GLOBAL ndb_metadata_check = @old_ndb_metadata_check; |
| 76 |
SET GLOBAL ndb_metadata_check_interval = @old_ndb_metadata_check_interval; |
| 77 |
--enable_query_log |
| 78 |
|
| 79 |
# Check that no tables have been synced. The tables aren't |
| 80 |
# synced due to the missing indexes and are treated as |
| 81 |
# temporary failures |
| 82 |
--let $synced_count = query_get_value(SHOW STATUS LIKE 'Ndb_metadata_synced_count', Value, 1) |
| 83 |
--let $assert_cond = "$synced_count" = "$initial_synced_count" |
| 84 |
--let $assert_text = Synced count has remained unchanged |
| 85 |
--source include/assert.inc |
| 86 |
SHOW TABLES; |
| 87 |
|
| 88 |
# Refresh count |
| 89 |
--let $initial_detected_count = query_get_value(SHOW STATUS LIKE 'Ndb_metadata_detected_count', Value, 1) |
| 90 |
|
| 91 |
--echo Rebuild indexes in NDB |
| 92 |
--exec $NDB_RESTORE -b $the_backup_id -n 1 --rebuild-indexes $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 93 |
|
| 94 |
--disable_query_log |
| 95 |
# Set low interval so changes are detected quickly |
| 96 |
SET GLOBAL ndb_metadata_check = true; |
| 97 |
SET GLOBAL ndb_metadata_check_interval = 5; |
| 98 |
--enable_query_log |
| 99 |
|
| 100 |
# Wait until the following 3 object changes are detected: |
| 101 |
# Table 'test.t1' |
| 102 |
# Table 'test.child' |
| 103 |
# Table 'test.parent' |
| 104 |
--let $expected_changes = 3 |
| 105 |
--let $max_wait = 30 |
| 106 |
--source wait_metadata_changes_detected.inc |
| 107 |
|
| 108 |
--disable_query_log |
| 109 |
# Changes have been detected, reset values |
| 110 |
SET GLOBAL ndb_metadata_check = @old_ndb_metadata_check; |
| 111 |
SET GLOBAL ndb_metadata_check_interval = @old_ndb_metadata_check_interval; |
| 112 |
--enable_query_log |
| 113 |
|
| 114 |
--echo Wait until the objects are synced |
| 115 |
--let $max_wait = 30 |
| 116 |
--source wait_metadata_synced.inc |
| 117 |
|
| 118 |
# Check that the 3 tables have been correctly synced |
| 119 |
SHOW TABLES; |
| 120 |
SHOW CREATE TABLE t1; |
| 121 |
--sorted_result |
| 122 |
SELECT * FROM t1; |
| 123 |
SHOW CREATE TABLE parent; |
| 124 |
--sorted_result |
| 125 |
SELECT * FROM parent; |
| 126 |
SHOW CREATE TABLE child; |
| 127 |
--sorted_result |
| 128 |
SELECT * FROM child; |
| 129 |
|
| 130 |
DROP TABLE t1,child,parent; |
| 131 |
|
| 132 |
--source suite/ndb/include/backup_restore_cleanup.inc |
| 133 |
--remove_file $NDB_TOOLS_OUTPUT |