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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
|
--source connect.inc
--source include/have_debug.inc
--source suite/ndb/include/backup_restore_setup.inc
#
# Schema detection + synchronization test
# This test contains all the cases that require debug options to be
# set in order to cause mismatches between NDB Dictionary and DD.
#
#
# Case 1:
# - Logfile group exists in DD but not NDB
# - Tablespace exists in DD but not NDB
#
SET GLOBAL debug = '+d,ndb_dd_client_lfg_force_commit,ndb_schema_trans_commit_fail,ndb_skip_create_tablespace_in_NDB';
SET @old_ndb_metadata_check = @@global.ndb_metadata_check;
SET @old_ndb_metadata_check_interval = @@global.ndb_metadata_check_interval;
--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)
CREATE LOGFILE GROUP lg1
ADD UNDOFILE 'lg1_undofile.dat'
INITIAL_SIZE 1M
UNDO_BUFFER_SIZE = 1M
ENGINE NDB;
CREATE TABLESPACE ts1
ADD DATAFILE 'ts1_datafile.dat'
USE LOGFILE GROUP lg1
INITIAL_SIZE 2M
ENGINE NDB;
SET GLOBAL debug = '-d,ndb_dd_client_lfg_force_commit,ndb_schema_trans_commit_fail,ndb_skip_create_tablespace_in_NDB';
# Enable metadata check with no interval so changes are detected quickly
SET GLOBAL ndb_metadata_check_interval = 0;
SET GLOBAL ndb_metadata_check = true;
# Wait until 2 mismatches (lg1 and ts1) are detected
--let $expected_changes = 2
--let $max_wait = 30
--source wait_metadata_changes_detected.inc
# Reset values
SET GLOBAL ndb_metadata_check = @old_ndb_metadata_check;
SET GLOBAL ndb_metadata_check_interval = @old_ndb_metadata_check_interval;
# Wait until the changes detected have been synced
--let $max_wait = 30
--source wait_metadata_synced.inc
# Check if the tablespace and logfile group have been removed from DD
CREATE LOGFILE GROUP lg1
ADD UNDOFILE 'lg1_undofile.dat'
INITIAL_SIZE 1M
UNDO_BUFFER_SIZE = 1M
ENGINE NDB;
CREATE TABLESPACE ts1
ADD DATAFILE 'ts1_datafile.dat'
USE LOGFILE GROUP lg1
INITIAL_SIZE 2M
ENGINE NDB;
ALTER TABLESPACE ts1
ADD DATAFILE 'ts1_datafile2.dat';
CREATE TABLE t1 (
a INT PRIMARY KEY,
b INT
) ENGINE NDB
TABLESPACE ts1
STORAGE DISK;
INSERT INTO t1 VALUES(1,1);
SELECT * FROM t1;
CREATE TABLESPACE ts2
ADD DATAFILE 'ts2_datafile.dat'
USE LOGFILE GROUP lg1
INITIAL_SIZE 2M
ENGINE NDB;
# Cleanup
DROP TABLE t1;
ALTER TABLESPACE ts1
DROP DATAFILE 'ts1_datafile.dat';
ALTER TABLESPACE ts1
DROP DATAFILE 'ts1_datafile2.dat';
DROP TABLESPACE ts1;
ALTER TABLESPACE ts2
DROP DATAFILE 'ts2_datafile.dat';
DROP TABLESPACE ts2;
DROP LOGFILE GROUP lg1
ENGINE NDB;
#
# Case 2:
# Check if the failure to sync objects is handled as expected. This involves
# the exclusion of objects from sync. While these objects are excluded, they
# shall not be detected.
#
CREATE TABLE t1 (
a INT PRIMARY KEY,
b VARCHAR(255)
) ENGINE NDB;
INSERT INTO t1 VALUES
(1, 'Rino'),
(2, 'Rino'),
(3, 'Rino Anto');
CREATE TABLE t2 (
a INT PRIMARY KEY,
b VARCHAR(255)
) ENGINE NDB;
INSERT INTO t2 VALUES
(4, 'Rino'),
(5, 'Rino'),
(6, 'Rino Anto');
CREATE TABLE t3 (
a INT PRIMARY KEY,
b VARCHAR(255)
) ENGINE NDB;
INSERT INTO t3 VALUES
(7, 'Rino'),
(8, 'Rino'),
(9, 'Rino Anto');
CREATE TABLE t4 (
a INT PRIMARY KEY,
b VARCHAR(255)
) ENGINE NDB;
INSERT INTO t4 VALUES(1, 'Hey Rino Anto');
CREATE DATABASE db1;
CREATE TABLE db1.t1 (
a INT PRIMARY KEY,
b VARCHAR(255)
) ENGINE NDB;
INSERT INTO db1.t1 VALUES
(1, 'Weasley'),
(2, 'Is Our'),
(3, 'King');
# backup
--disable_query_log
--source include/ndb_backup.inc
--enable_query_log
# Drop tables
DROP TABLE t1,t2,t3,t4;
DROP DATABASE db1;
# Restore into NDB
--exec $NDB_RESTORE -b $the_backup_id -n 1 -m -r $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
CREATE TABLE t5 (
a INT PRIMARY KEY,
b VARCHAR(255)
) ENGINE NDB;
# Drop table from NDB only to cause mismatch
--exec $NDB_DROP_TABLE -d test t5 >> $NDB_TOOLS_OUTPUT
# 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)
# Force synch to fail
SET GLOBAL debug = '+d,ndb_metadata_sync_fail';
# Suppress error
--disable_query_log ONCE
CALL mtr.add_suppression("Binlog: Failed to synchronize table");
# Enable metadata check with no interval so changes are detected quickly
SET GLOBAL ndb_metadata_check_interval = 0;
SET GLOBAL ndb_metadata_check = true;
# Wait until the following 6 object changes are detected:
# Schema 'db1'
# Table 'ndb_ddl_test.t1'
# Table 'ndb_ddl_test.t2'
# Table 'ndb_ddl_test.t3'
# Table 'ndb_ddl_test.t4'
# Table 'ndb_ddl_test.t5'
--let $expected_changes = 6
--let $max_wait = 60
--source wait_metadata_changes_detected.inc
# Reset values
SET GLOBAL ndb_metadata_check = @old_ndb_metadata_check;
SET GLOBAL ndb_metadata_check_interval = @old_ndb_metadata_check_interval;
# Wait until the changes detected have been synced
--let $max_wait = 60
--source wait_metadata_synced.inc
# Verify that the objects have been excluded
SHOW STATUS LIKE 'Ndb_metadata_excluded_count';
--sorted_result
SELECT * FROM performance_schema.ndb_sync_excluded_objects;
# Sleep for some time to let a couple of cycles of detection
# occur. Since the objects have been excluded, the mismatches
# should not be detected and the number of changes detected
# should remain unchanged
--let $initial_detected_count = query_get_value(SHOW STATUS LIKE 'Ndb_metadata_detected_count', Value, 1)
# Enable metadata check with no interval so changes are detected quickly
SET GLOBAL ndb_metadata_check_interval = 0;
SET GLOBAL ndb_metadata_check = true;
--sleep 5
--let $current_changes_detected = query_get_value(SHOW STATUS LIKE 'Ndb_metadata_detected_count', Value, 1)
if ($current_changes_detected != $initial_detected_count)
{
--echo $current_changes_detected changes detected when $initial_detected_count changes were expected
--die Changes detected even when objects were excluded
}
# Reset values
SET GLOBAL ndb_metadata_check = @old_ndb_metadata_check;
SET GLOBAL ndb_metadata_check_interval = @old_ndb_metadata_check_interval;
# Manually sync the tables through "discovery".
# This will result in the tables being no longer
# excluded during the next detection cycle
--sorted_result
SELECT * FROM t1;
--sorted_result
SELECT * FROM t2;
--sorted_result
SELECT * FROM t3;
--sorted_result
SELECT * FROM t4;
DROP TABLE IF EXISTS t5;
CREATE DATABASE db1;
--sorted_result
SELECT * FROM db1.t1;
# Enable metadata check with no interval to clear the excluded objects
# list quickly
SET GLOBAL ndb_metadata_check_interval = 0;
SET GLOBAL ndb_metadata_check = true;
# Wait until the objects are no longer excluded
--let $max_wait = 30
--source wait_metadata_sync_zero_excluded.inc
SELECT COUNT(*) FROM performance_schema.ndb_sync_excluded_objects;
# Reset values
SET GLOBAL ndb_metadata_check = @old_ndb_metadata_check;
SET GLOBAL ndb_metadata_check_interval = @old_ndb_metadata_check_interval;
SET GLOBAL debug = '-d,ndb_metadata_sync_fail';
# Cleanup
DROP TABLE t1,t2,t3,t4;
DROP DATABASE db1;
--source suite/ndb/include/backup_restore_cleanup.inc
--remove_file $NDB_TOOLS_OUTPUT
|