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