| 1 |
--source include/have_multi_ndb.inc |
| 2 |
--source suite/ndb/include/backup_restore_setup.inc |
| 3 |
|
| 4 |
--echo # |
| 5 |
--echo # WL#12731: Improve database synchronization during mysqld startup |
| 6 |
--echo # |
| 7 |
|
| 8 |
# Test the database discovery in mysqlds during startup. |
| 9 |
# This is done by the following steps : |
| 10 |
# 1. Bring up a cluster with multiple mysqlds connected to it. |
| 11 |
# 2. Create few databases and tables on both of them. |
| 12 |
# 3. Bring down one mysqld. |
| 13 |
# 4. Create, alter, drop databases in the other mysqld. |
| 14 |
# 5. Start the mysqld which was down and check if the databases are in expected states. |
| 15 |
|
| 16 |
--echo # Setup - create few databases and tables so that the alter and drop statements can be tested. |
| 17 |
--connection server1 |
| 18 |
create database alter_db1 charset utf8mb4; |
| 19 |
create table alter_db1.t1 (a int); |
| 20 |
|
| 21 |
create database drop_db1; |
| 22 |
create database drop_db2; |
| 23 |
create table drop_db2.t1(a int) engine ndb; |
| 24 |
create database drop_db3; |
| 25 |
create table drop_db3.t1(a int); |
| 26 |
|
| 27 |
create database restore_db1; |
| 28 |
create table restore_db1.t1(a int) engine ndb; |
| 29 |
create database restore_db2 charset latin1; |
| 30 |
create table restore_db2.t1(a int) engine ndb; |
| 31 |
create database restore_db3 charset latin1; |
| 32 |
create table restore_db3.t1(a int) engine ndb; |
| 33 |
|
| 34 |
--echo # Take a backup of the current setup |
| 35 |
--source include/ndb_backup.inc |
| 36 |
--echo # Drop restore_db1,restore_db2 to check how the server startup handles database restores |
| 37 |
drop database restore_db1; |
| 38 |
drop database restore_db2; |
| 39 |
|
| 40 |
--echo # |
| 41 |
--echo # Shutdown Server1 |
| 42 |
--echo # |
| 43 |
# Write file to make mysql-test-run.pl expect the restart, |
| 44 |
# but don't start it until it's told to. |
| 45 |
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.1.expect |
| 46 |
wait |
| 47 |
EOF |
| 48 |
# Send shutdown to the connected server |
| 49 |
--shutdown_server |
| 50 |
# Wait until server is gone. |
| 51 |
--source include/wait_until_disconnected.inc |
| 52 |
|
| 53 |
--echo # |
| 54 |
--echo # Run DDLs on Server2 when server1 is down |
| 55 |
--echo # |
| 56 |
--connection server2 |
| 57 |
|
| 58 |
--echo # Create a database |
| 59 |
create database create_db; |
| 60 |
--echo # Add tables to it |
| 61 |
create table create_db.t1(a int) engine ndb; |
| 62 |
create table create_db.t2(a int); |
| 63 |
|
| 64 |
--echo # Alter already existing databases |
| 65 |
alter database alter_db1 charset latin1; |
| 66 |
--echo # Create and alter a database |
| 67 |
create database alter_db2 charset utf8mb4; |
| 68 |
alter database alter_db2 charset latin1; |
| 69 |
|
| 70 |
--echo # Drop databases |
| 71 |
drop database drop_db1; |
| 72 |
drop database drop_db2; |
| 73 |
drop database drop_db3; |
| 74 |
|
| 75 |
--echo # Drop database restore_db3 and then restore restore_db1, restore_db2, restore_db3 |
| 76 |
drop database restore_db3; |
| 77 |
--exec $NDB_RESTORE -b $the_backup_id -n 1 -m --include-databases=restore_db1,restore_db2,restore_db3 $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT |
| 78 |
|
| 79 |
--echo # |
| 80 |
--echo # Startup server1 |
| 81 |
--echo # |
| 82 |
--connection server1 |
| 83 |
# Write file to make mysql-test-run.pl start up the server again. |
| 84 |
--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.1.expect |
| 85 |
restart |
| 86 |
EOF |
| 87 |
# Turn on reconnect. |
| 88 |
--enable_reconnect |
| 89 |
# Call script that will poll the server waiting for it to be back online again. |
| 90 |
--source include/wait_until_connected_again.inc |
| 91 |
# Turn off reconnect again. |
| 92 |
--disable_reconnect |
| 93 |
|
| 94 |
--echo # |
| 95 |
--echo # Now check that the databases are in expected states |
| 96 |
--echo # |
| 97 |
|
| 98 |
--echo # Verify that create_db has been discovered |
| 99 |
show create database create_db; |
| 100 |
--echo # Verify t1 has been created. t2 won't be as it is local to Server 2. |
| 101 |
show tables from create_db; |
| 102 |
show create table create_db.t1; |
| 103 |
--error ER_NO_SUCH_TABLE |
| 104 |
show create table create_db.t2; |
| 105 |
|
| 106 |
--echo # Verify that the database alter_db1 were properly altered |
| 107 |
show create database alter_db1; |
| 108 |
--echo # Check that alter_db2 is created and altered |
| 109 |
show create database alter_db2; |
| 110 |
|
| 111 |
--echo # Check the states of databases that were dropped |
| 112 |
--echo # Databases drop_db1 and drop_db2 should be dropped. |
| 113 |
--error ER_BAD_DB_ERROR |
| 114 |
show create database drop_db1; |
| 115 |
--error ER_BAD_DB_ERROR |
| 116 |
show create database drop_db2; |
| 117 |
--echo # Database drop_db3 should be preserved. |
| 118 |
show create database drop_db3; |
| 119 |
# Also, suppress the warning that would have been generated during startup |
| 120 |
--disable_query_log ONCE |
| 121 |
call mtr.add_suppression("Database 'drop_db3' has tables. Skipped dropping it"); |
| 122 |
|
| 123 |
--echo # Check that the databases and tables that were |
| 124 |
--echo # dropped and restored are now discovered |
| 125 |
show create database restore_db1; |
| 126 |
show create table restore_db1.t1; |
| 127 |
|
| 128 |
--echo # restore_db2 was dropped when both mysqlds were alive |
| 129 |
--echo # so it would have been discovered with default charset |
| 130 |
show create database restore_db2; |
| 131 |
show create table restore_db2.t1; |
| 132 |
|
| 133 |
--echo # restore_db3 was dropped when server1 was down |
| 134 |
--echo # when server1 came up, it should have been |
| 135 |
--echo # preserved the database with previous setting |
| 136 |
show create database restore_db3; |
| 137 |
show create table restore_db3.t1; |
| 138 |
# Also, suppress the warning that would have been generated during startup |
| 139 |
--disable_query_log ONCE |
| 140 |
call mtr.add_suppression("Database 'restore_db3' has tables. Skipped dropping it"); |
| 141 |
|
| 142 |
--echo # |
| 143 |
--echo # Cleanup |
| 144 |
--echo # |
| 145 |
|
| 146 |
--connection server2 |
| 147 |
drop table create_db.t2; |
| 148 |
--connection server1 |
| 149 |
drop table drop_db3.t1; |
| 150 |
|
| 151 |
drop database create_db; |
| 152 |
drop database alter_db1; |
| 153 |
drop database alter_db2; |
| 154 |
drop database drop_db3; |
| 155 |
drop database restore_db1; |
| 156 |
drop database restore_db2; |
| 157 |
drop database restore_db3; |
| 158 |
|
| 159 |
--source suite/ndb/include/backup_restore_cleanup.inc |
| 160 |
--remove_file $NDB_TOOLS_OUTPUT |