--source setup.inc --source suite/ndb/include/backup_restore_setup.inc # # Basic schema detection + synchronization test # - Cause mismatch between NDB Dictionary and DD # - Check if these mismatches are detected properly by # Ndb_metadata_change_monitor thread # - Check if these mismatches detected are synchronized # # Create logfile group, tablespace, and tables in addition to # those created in setup.inc 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; USE ndb_ddl_test; CREATE TABLE t10 ( a INT PRIMARY KEY, b VARCHAR(255) ) ENGINE NDB TABLESPACE ts1 STORAGE DISK; INSERT INTO t10 VALUES(1, 'Poirot'); CREATE DATABASE ndb_ddl_test3; USE ndb_ddl_test3; CREATE TABLE t1 ( a INT, b INT, PRIMARY KEY(a,b) ) ENGINE NDB; CREATE TABLE t2( a INT PRIMARY KEY, b VARCHAR(255) ) ENGINE NDB; # backup --disable_query_log --source include/ndb_backup.inc --enable_query_log # Create a few more databases and tests CREATE DATABASE ndb_ddl_test4; USE ndb_ddl_test4; CREATE TABLE t1 ( a INT, b INT, PRIMARY KEY(a,b) ) ENGINE NDB; CREATE TABLE t2( a INT PRIMARY KEY, b VARCHAR(255) ) ENGINE NDB; CREATE DATABASE ndb_ddl_test5; USE ndb_ddl_test5; CREATE TABLE t1 ( a INT, b INT, PRIMARY KEY(a,b) ) ENGINE NDB; USE ndb_ddl_test; # Drop half the tables from ndb_ddl_test database --let $counter = 6 while ($counter <= 10) { let $tx=t$counter; --eval DROP TABLE $tx --inc $counter } ALTER TABLESPACE ts1 DROP DATAFILE 'ts1_datafile.dat'; DROP TABLESPACE ts1; DROP LOGFILE GROUP lg1 ENGINE NDB; # Drop all tables in ndb_ddl_test3 USE ndb_ddl_test3; DROP TABLE t1; DROP TABLE t2; # Restore into NDB, skip tables in ndb_ddl_test database that already exist --exec $NDB_RESTORE -b $the_backup_id -n 1 -m -r --exclude-tables=ndb_ddl_test.t1,ndb_ddl_test.t2,ndb_ddl_test.t3,ndb_ddl_test.t4,ndb_ddl_test.t5 $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT --exec $NDB_RESTORE -b $the_backup_id -n 2 -r --exclude-tables=ndb_ddl_test.t1,ndb_ddl_test.t2,ndb_ddl_test.t3,ndb_ddl_test.t4,ndb_ddl_test.t5 $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT # Drop tables from NDB only to cause mismatch --exec $NDB_DROP_TABLE --no-defaults -d ndb_ddl_test4 t1 >> $NDB_TOOLS_OUTPUT --exec $NDB_DROP_TABLE --no-defaults -d ndb_ddl_test5 t1 >> $NDB_TOOLS_OUTPUT SET @old_ndb_metadata_check = @@global.ndb_metadata_check; SET @old_ndb_metadata_check_interval = @@global.ndb_metadata_check_interval; # 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) # Check if both variables are global --error ER_GLOBAL_VARIABLE SET SESSION ndb_metadata_check = 1; --error ER_GLOBAL_VARIABLE SET SESSION ndb_metadata_check_interval = 5; # Enable metadata check with no interval so changes are detected quickly SET GLOBAL ndb_metadata_check_interval = 0; SET GLOBAL ndb_metadata_check = 1; # Wait until the following 11 object changes are detected: # Logfile group 'lg1' # Tablespace 'ts1' # Table 'ndb_ddl_test.t6' # Table 'ndb_ddl_test.t7' # Table 'ndb_ddl_test.t8' # Table 'ndb_ddl_test.t9' # Table 'ndb_ddl_test.t10' # Table 'ndb_ddl_test3.t1' # Table 'ndb_ddl_test3.t2' # Table 'ndb_ddl_test4.t1' # Table 'ndb_ddl_test5.t1' --let $expected_changes = 11 --let $max_wait = 60 --source wait_metadata_changes_detected.inc # 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; # Wait until the changes detected have been synced --let $max_wait = 60 --source wait_metadata_synced.inc # Run some DDL statements and queries on the tables synced --sorted_result SELECT * FROM ndb_ddl_test.t6; --sorted_result SELECT * FROM ndb_ddl_test.t8; --sorted_result SELECT * FROM ndb_ddl_test.t10; ALTER TABLE ndb_ddl_test3.t1 ADD COLUMN c VARCHAR(255); INSERT INTO ndb_ddl_test3.t1 VALUES(1, 1, 'Use your little grey cells mon ami'); SELECT * FROM ndb_ddl_test3.t1; --error ER_NO_SUCH_TABLE SHOW CREATE TABLE ndb_ddl_test4.t1; --error ER_NO_SUCH_TABLE SHOW CREATE TABLE ndb_ddl_test5.t1; # Check if tablespace and logfile group work fine after sync CREATE TABLESPACE ts2 ADD DATAFILE 'ts2_datafile.dat' USE LOGFILE GROUP lg1 INITIAL_SIZE 2M ENGINE NDB; ALTER TABLESPACE ts1 ADD DATAFILE 'ts1_datafile2.dat'; CREATE TABLE ndb_ddl_test4.t1 ( a INT PRIMARY KEY, b INT ) ENGINE NDB; INSERT INTO ndb_ddl_test4.t1 VALUES(1,1); SELECT * FROM ndb_ddl_test4.t1; # Cleanup DROP DATABASE ndb_ddl_test3; DROP DATABASE ndb_ddl_test4; DROP DATABASE ndb_ddl_test5; --source cleanup.inc 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; --source suite/ndb/include/backup_restore_cleanup.inc --remove_file $NDB_TOOLS_OUTPUT