375 lines
8.4 KiB
Plaintext
375 lines
8.4 KiB
Plaintext
-- source include/have_multi_ndb.inc
|
|
-- source include/have_binlog_format_mixed_or_row.inc
|
|
|
|
--disable_warnings
|
|
--connection server1
|
|
reset master;
|
|
--connection server2
|
|
reset master;
|
|
--enable_warnings
|
|
|
|
#
|
|
# Basic test to see if DDL distribution works across
|
|
# binlogs in different MySQL Server(s)
|
|
#
|
|
|
|
# create database
|
|
--connection server1
|
|
create database mysqltest;
|
|
|
|
# create table
|
|
--connection server1
|
|
use mysqltest;
|
|
create table t1 (a int primary key) engine=ndb;
|
|
|
|
--connection server2
|
|
create table t2 (a int primary key) engine=ndb;
|
|
--source include/show_binlog_events.inc
|
|
|
|
--connection server1
|
|
--source include/show_binlog_events.inc
|
|
|
|
# alter table
|
|
--connection server1
|
|
reset master;
|
|
--connection server2
|
|
reset master;
|
|
|
|
--connection server2
|
|
alter table t2 add column (b int);
|
|
|
|
--connection server1
|
|
--source include/show_binlog_events.inc
|
|
|
|
# alter database
|
|
--connection server1
|
|
reset master;
|
|
--connection server2
|
|
reset master;
|
|
|
|
--connection server2
|
|
ALTER DATABASE mysqltest CHARACTER SET latin1;
|
|
|
|
|
|
--connection server1
|
|
--source include/show_binlog_events.inc
|
|
|
|
#--connection server2
|
|
drop table mysqltest.t1;
|
|
|
|
# drop database and drop should come after data events
|
|
--connection server1
|
|
reset master;
|
|
--connection server2
|
|
reset master;
|
|
|
|
--connection server1
|
|
use test;
|
|
insert into t2 values (1,2);
|
|
drop database mysqltest;
|
|
create table t1 (a int primary key) engine=ndb;
|
|
|
|
--connection server2
|
|
--source include/show_binlog_events.inc
|
|
|
|
--connection server2
|
|
drop table t2;
|
|
|
|
# logfile groups and table spaces
|
|
--connection server1
|
|
reset master;
|
|
--connection server2
|
|
reset master;
|
|
|
|
--connection server1
|
|
CREATE LOGFILE GROUP lg1
|
|
ADD UNDOFILE 'undofile.dat'
|
|
INITIAL_SIZE 16M
|
|
UNDO_BUFFER_SIZE = 1M
|
|
ENGINE=NDB;
|
|
|
|
ALTER LOGFILE GROUP lg1
|
|
ADD UNDOFILE 'undofile02.dat'
|
|
INITIAL_SIZE = 4M
|
|
ENGINE=NDB;
|
|
|
|
CREATE TABLESPACE ts1
|
|
ADD DATAFILE 'datafile.dat'
|
|
USE LOGFILE GROUP lg1
|
|
INITIAL_SIZE 12M
|
|
ENGINE NDB;
|
|
|
|
ALTER TABLESPACE ts1
|
|
ADD DATAFILE 'datafile02.dat'
|
|
INITIAL_SIZE = 4M;
|
|
|
|
ALTER TABLESPACE ts1
|
|
DROP DATAFILE 'datafile.dat';
|
|
|
|
ALTER TABLESPACE ts1
|
|
DROP DATAFILE 'datafile02.dat';
|
|
|
|
DROP TABLESPACE ts1;
|
|
|
|
DROP LOGFILE GROUP lg1
|
|
ENGINE =NDB;
|
|
|
|
--connection server2
|
|
--source include/show_binlog_events.inc
|
|
|
|
drop table t1;
|
|
|
|
#
|
|
# Bug #17827 cluster: rename of several tables in one statement,
|
|
# gets multiply logged
|
|
#
|
|
--connection server1
|
|
reset master;
|
|
show tables;
|
|
--connection server2
|
|
reset master;
|
|
show tables;
|
|
|
|
--connection server1
|
|
create table t1 (a int key) engine=ndb;
|
|
create table t2 (a int key) engine=ndb;
|
|
create table t3 (a int key) engine=ndb;
|
|
rename table t3 to t4, t2 to t3, t1 to t2, t4 to t1;
|
|
--connection server2
|
|
--source include/show_binlog_events.inc
|
|
|
|
drop table t1;
|
|
drop table t2;
|
|
drop table t3;
|
|
|
|
#
|
|
# Bug #17838 binlog not setup on seconday master after rename
|
|
#
|
|
#
|
|
--connection server1
|
|
reset master;
|
|
show tables;
|
|
--connection server2
|
|
reset master;
|
|
show tables;
|
|
|
|
--connection server1
|
|
create table t1 (a int key) engine=ndb;
|
|
insert into t1 values(1);
|
|
rename table t1 to t2;
|
|
insert into t2 values(2);
|
|
|
|
# now we should see data in table t1 _and_ t2
|
|
# prior to bug fix, data was missing for t2
|
|
--connection server2
|
|
drop table t2;
|
|
--source include/show_binlog_events.inc
|
|
|
|
##########################
|
|
# Bug#22135584: BINLOG CONTAINS SCHEMA EVENTS IN INCORRECT ORDER
|
|
#
|
|
# DDL operations are sometimes inserted in the incorrect relative order
|
|
# vs. the DML operations.
|
|
##########################
|
|
--connection server1
|
|
reset master;
|
|
--connection server2
|
|
reset master;
|
|
|
|
##################################################
|
|
# Check whether we have a debug compiled binary:
|
|
# @@global.debug can't be referred without this.
|
|
# However, instead of skipping entire test without debug,
|
|
# we run it without setting the specific debug flags.
|
|
###################################################
|
|
--connection server2
|
|
--let $have_debug= `select (version() like '%debug%')`
|
|
|
|
disable_query_log;
|
|
if ($have_debug)
|
|
{
|
|
# Force server2 to yield the CPU inbetween polling the event buffer
|
|
set @save_debug= @@global.debug;
|
|
set global debug='+d,ndb_binlog_injector_yield_before_schema_pollEvent';
|
|
}
|
|
enable_query_log;
|
|
|
|
--connection server1
|
|
use test;
|
|
|
|
--echo The relative order between DML and DDL statements below are
|
|
--echo expected to follow the same order in binlog as shown below.
|
|
let $i=5;
|
|
while ($i)
|
|
{
|
|
create database mysqltest;
|
|
create table t1 (a int primary key) engine=ndb;
|
|
insert into t1 values (1);
|
|
drop database mysqltest;
|
|
drop table t1;
|
|
dec $i;
|
|
}
|
|
# Dummy synchronization to flush prior events to binlog
|
|
create table dummy (dummyk int primary key) engine = ndb;
|
|
|
|
--connection server2
|
|
disable_query_log;
|
|
if ($have_debug)
|
|
{
|
|
set global debug= @save_debug;
|
|
}
|
|
enable_query_log;
|
|
|
|
--connection server2
|
|
|
|
# Ensure that synchronization dummy reached log
|
|
drop table dummy;
|
|
--source include/show_binlog_events.inc
|
|
|
|
##########################
|
|
# Bug#22842538:
|
|
#
|
|
# New mysqld's joining the schema distribution may cause
|
|
# ongoing DDL operations to never complete -> timeout
|
|
#
|
|
##########################
|
|
connection server1;
|
|
|
|
|
|
# Procedure p1 communicate through 'progress' table
|
|
CREATE TABLE progress(
|
|
cnt int, stop_flag int
|
|
) ENGINE NDB;
|
|
|
|
|
|
# Create a procedure for producing a background load of
|
|
# DDL operations. Any operations, like a CREATE TABLE, would
|
|
# do. However, we have experienced that CREATE LOGFILE seems
|
|
# to be most likely to trigger this bug (Due to timing?)
|
|
#
|
|
disable_query_log;
|
|
delimiter %;
|
|
create procedure p1()
|
|
begin
|
|
declare done int default 0;
|
|
repeat
|
|
UPDATE progress set cnt=cnt+1;
|
|
COMMIT;
|
|
CREATE LOGFILE GROUP lg_1
|
|
ADD UNDOFILE 'undo_1.dat'
|
|
INITIAL_SIZE 4M
|
|
UNDO_BUFFER_SIZE 2M
|
|
ENGINE NDB;
|
|
UPDATE progress set cnt=cnt+1;
|
|
COMMIT;
|
|
DROP LOGFILE GROUP lg_1 ENGINE NDB;
|
|
SELECT stop_flag INTO done FROM progress;
|
|
until done end repeat;
|
|
end%
|
|
delimiter ;%
|
|
enable_query_log;
|
|
|
|
|
|
insert into progress value(0,0);
|
|
|
|
--echo Start background load distributing schema changes.
|
|
send call p1();
|
|
|
|
connection server2;
|
|
let $1 = 4;
|
|
while ($1)
|
|
{
|
|
# Ignore the warning generated by ndbcluster's binlog thread
|
|
# when cluster is restarted
|
|
--disable_query_log ONCE
|
|
call mtr.add_suppression("mysqld startup An incident event has been written");
|
|
|
|
--echo Restart mysqld 'server2'
|
|
let $mysqld_name=mysqld.2.1;
|
|
--source include/restart_mysqld.inc
|
|
|
|
--echo Checking for schema ops. still making progress
|
|
let $initial_cnt = `select cnt from progress`;
|
|
let $progress_cnt = $initial_cnt;
|
|
|
|
let $max_wait = 10;
|
|
while ($progress_cnt == $initial_cnt)
|
|
{
|
|
sleep 1;
|
|
dec $max_wait;
|
|
if ($max_wait == 0)
|
|
{
|
|
die Schema distribution timed out without progress;
|
|
}
|
|
let $progress_cnt = `select cnt from progress`;
|
|
}
|
|
dec $1;
|
|
}
|
|
|
|
--echo Stopping background load distributing schema changes.
|
|
update progress set stop_flag=1;
|
|
|
|
connection server1;
|
|
|
|
--echo Wait for background schema distribution load to complete.
|
|
reap;
|
|
|
|
--echo Cleanup
|
|
drop procedure p1;
|
|
drop table progress;
|
|
|
|
--echo #
|
|
--echo # WL#12936 : Implement DDL transaction context logger in ndbcluster
|
|
--echo #
|
|
|
|
# When a DDL transaction fails, it will be rolled back and distributed to
|
|
# other connected mysql servers. But even before the failure, the actual
|
|
# changes would have been distributed to other participants and the query
|
|
# would be logged in their binlogs. This can't be avoided. This testcase
|
|
# is here to document this behaviour.
|
|
|
|
--connection server1
|
|
reset master;
|
|
show tables;
|
|
--connection server2
|
|
reset master;
|
|
show tables;
|
|
|
|
--connection server1
|
|
--echo # Setup
|
|
CREATE TABLE t1 (
|
|
a int,
|
|
b int
|
|
) ENGINE NDB;
|
|
|
|
INSERT INTO t1 VALUES (1, NULL);
|
|
|
|
# Use CREATE TABLE .. AS SELECT .. FROM t1 and create a similar table t1
|
|
# with column a NOT NULL. This will fail when the Server tries to copy rows
|
|
# from t1 to t2 but only after the CREATE has been distributed to other
|
|
# other tables. The CREATE should fail and drop the table in NDB and across
|
|
# drop the table in NDB and across all connected mysqlds during
|
|
# rollback. But the participant binlog will have the CREATE query.
|
|
--error ER_BAD_NULL_ERROR
|
|
CREATE TABLE t2 (
|
|
a int,
|
|
b int not null
|
|
) ENGINE NDB
|
|
AS SELECT * FROM t1;
|
|
|
|
--echo # Verify that table does not exist
|
|
--error ER_NO_SUCH_TABLE
|
|
SELECT * FROM t2;
|
|
--echo # Verify that the CREATE TABLE t2 query is not present in binlog
|
|
--source include/show_binlog_events.inc
|
|
|
|
--connection server2
|
|
--echo # Table should not exist in participant also
|
|
--error ER_NO_SUCH_TABLE
|
|
SELECT * FROM t2;
|
|
--echo # Verify that the CREATE TABLE t2 query is present in binlog
|
|
--source include/show_binlog_events.inc
|
|
|
|
--echo #Cleanup
|
|
DROP TABLE t1;
|