162 lines
5.1 KiB
Plaintext
162 lines
5.1 KiB
Plaintext
--source include/have_multi_ndb.inc
|
|
--source suite/ndb/include/backup_restore_setup.inc
|
|
|
|
--echo #
|
|
--echo # WL#12731: Improve database synchronization during mysqld startup
|
|
--echo #
|
|
|
|
# Test the database discovery in mysqlds during startup.
|
|
# This is done by the following steps :
|
|
# 1. Bring up a cluster with multiple mysqlds connected to it.
|
|
# 2. Create few databases and tables on both of them.
|
|
# 3. Bring down one mysqld.
|
|
# 4. Create, alter, drop databases in the other mysqld.
|
|
# 5. Start the mysqld which was down and check if the databases are in expected states.
|
|
|
|
--echo # Setup - create few databases and tables so that the alter and drop statements can be tested.
|
|
--connection server1
|
|
create database alter_db1 charset utf8mb4;
|
|
create table alter_db1.t1 (a int);
|
|
|
|
create database drop_db1;
|
|
create database drop_db2;
|
|
create table drop_db2.t1(a int) engine ndb;
|
|
create database drop_db3;
|
|
create table drop_db3.t1(a int);
|
|
|
|
create database restore_db1;
|
|
create table restore_db1.t1(a int) engine ndb;
|
|
create database restore_db2 charset latin1;
|
|
create table restore_db2.t1(a int) engine ndb;
|
|
create database restore_db3 charset latin1;
|
|
create table restore_db3.t1(a int) engine ndb;
|
|
|
|
--echo # Take a backup of the current setup
|
|
--source include/ndb_backup.inc
|
|
--echo # Drop restore_db1,restore_db2 to check how the server startup handles database restores
|
|
drop database restore_db1;
|
|
drop database restore_db2;
|
|
|
|
--echo #
|
|
--echo # Shutdown Server1
|
|
--echo #
|
|
# Write file to make mysql-test-run.pl expect the restart,
|
|
# but don't start it until it's told to.
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.1.expect
|
|
wait
|
|
EOF
|
|
# Send shutdown to the connected server and give
|
|
# it 30 seconds to die before zapping it.
|
|
shutdown_server 30;
|
|
# Wait until server is gone.
|
|
--source include/wait_until_disconnected.inc
|
|
|
|
--echo #
|
|
--echo # Run DDLs on Server2 when server1 is down
|
|
--echo #
|
|
--connection server2
|
|
|
|
--echo # Create a database
|
|
create database create_db;
|
|
--echo # Add tables to it
|
|
create table create_db.t1(a int) engine ndb;
|
|
create table create_db.t2(a int);
|
|
|
|
--echo # Alter already existing databases
|
|
alter database alter_db1 charset latin1;
|
|
--echo # Create and alter a database
|
|
create database alter_db2 charset utf8mb4;
|
|
alter database alter_db2 charset latin1;
|
|
|
|
--echo # Drop databases
|
|
drop database drop_db1;
|
|
drop database drop_db2;
|
|
drop database drop_db3;
|
|
|
|
--echo # Drop database restore_db3 and then restore restore_db1, restore_db2, restore_db3
|
|
drop database restore_db3;
|
|
--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
|
|
|
|
--echo #
|
|
--echo # Startup server1
|
|
--echo #
|
|
--connection server1
|
|
# Write file to make mysql-test-run.pl start up the server again.
|
|
--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.1.expect
|
|
restart
|
|
EOF
|
|
# Turn on reconnect.
|
|
--enable_reconnect
|
|
# Call script that will poll the server waiting for it to be back online again.
|
|
--source include/wait_until_connected_again.inc
|
|
# Turn off reconnect again.
|
|
--disable_reconnect
|
|
|
|
--echo #
|
|
--echo # Now check that the databases are in expected states
|
|
--echo #
|
|
|
|
--echo # Verify that create_db has been discovered
|
|
show create database create_db;
|
|
--echo # Verify t1 has been created. t2 won't be as it is local to Server 2.
|
|
show tables from create_db;
|
|
show create table create_db.t1;
|
|
--error ER_NO_SUCH_TABLE
|
|
show create table create_db.t2;
|
|
|
|
--echo # Verify that the database alter_db1 were properly altered
|
|
show create database alter_db1;
|
|
--echo # Check that alter_db2 is created and altered
|
|
show create database alter_db2;
|
|
|
|
--echo # Check the states of databases that were dropped
|
|
--echo # Databases drop_db1 and drop_db2 should be dropped.
|
|
--error ER_BAD_DB_ERROR
|
|
show create database drop_db1;
|
|
--error ER_BAD_DB_ERROR
|
|
show create database drop_db2;
|
|
--echo # Database drop_db3 should be preserved.
|
|
show create database drop_db3;
|
|
# Also, suppress the warning that would have been generated during startup
|
|
--disable_query_log ONCE
|
|
call mtr.add_suppression("Database 'drop_db3' has tables. Skipped dropping it");
|
|
|
|
--echo # Check that the databases and tables that were
|
|
--echo # dropped and restored are now discovered
|
|
show create database restore_db1;
|
|
show create table restore_db1.t1;
|
|
|
|
--echo # restore_db2 was dropped when both mysqlds were alive
|
|
--echo # so it would have been discovered with default charset
|
|
show create database restore_db2;
|
|
show create table restore_db2.t1;
|
|
|
|
--echo # restore_db3 was dropped when server1 was down
|
|
--echo # when server1 came up, it should have been
|
|
--echo # preserved the database with previous setting
|
|
show create database restore_db3;
|
|
show create table restore_db3.t1;
|
|
# Also, suppress the warning that would have been generated during startup
|
|
--disable_query_log ONCE
|
|
call mtr.add_suppression("Database 'restore_db3' has tables. Skipped dropping it");
|
|
|
|
--echo #
|
|
--echo # Cleanup
|
|
--echo #
|
|
|
|
--connection server2
|
|
drop table create_db.t2;
|
|
--connection server1
|
|
drop table drop_db3.t1;
|
|
|
|
drop database create_db;
|
|
drop database alter_db1;
|
|
drop database alter_db2;
|
|
drop database drop_db3;
|
|
drop database restore_db1;
|
|
drop database restore_db2;
|
|
drop database restore_db3;
|
|
|
|
--source suite/ndb/include/backup_restore_cleanup.inc
|
|
--remove_file $NDB_TOOLS_OUTPUT
|