polardbxengine/mysql-test/suite/ndb/t/ndb_fk_restart.test

180 lines
5.3 KiB
Plaintext

-- source include/have_ndb.inc
-- source ndb_mgm.inc
-- source ndb_waiter.inc
# Ignore the warning generated by ndbcluster's binlog thread
# when cluster is restarted
--disable_query_log ONCE
call mtr.add_suppression("cluster disconnect An incident event has been written");
# Ignore the warning generated by ndbcluster's binlog thread
# when cluster is restarted - also on the second mysqld
connect(mysqld2,127.0.0.1,root,,test,$MASTER_MYPORT1);
connection mysqld2;
--disable_query_log ONCE
call mtr.add_suppression("cluster disconnect An incident event has been written");
connection default;
# Create rows table and fill with 1000 rows
create table `rows`(a int primary key) engine=ndb;
--disable_query_log
let $i = 0;
while($i < 1000)
{
eval insert into `rows`(a) values ($i);
inc $i;
}
--enable_query_log
select count(a) from `rows`;
create table p1 (name varchar(255),
id int(11) auto_increment,
parent_id int,
parent_c1 int,
parent_c2 int,
primary key(id),
unique(name),
key k2(parent_id),
unique(parent_c1, parent_c2)
)engine = ndb;
create table c1(c1 varchar(100),
id int(11),
primary key(c1),
unique key abc (id),
key (c1),
constraint fk1 foreign key (id) references p1 (id)
) engine=ndb;
create table c2(c2 varchar(100),
id int(11),
parent_temp int,
parent_rc1 int,
parent_rc2 int,
parent_rc3 int,
primary key(c2),
unique key abc(c2),
unique key abd(parent_temp),
constraint c2_fk1 foreign key (id) references p1 (id),
constraint c2_fk2 foreign key (parent_rc1, parent_rc2) references p1(parent_c1, parent_c2),
constraint c2_fk3 foreign key (parent_rc3) references c1(id)
) engine=ndb;
# Populate parent table
insert into p1(parent_id) select a from `rows`;
select count(1) from test.p1;
--echo -- Show Fks working
set @n=0; insert into test.c1(c1,id) select @N:=@N+1,id from p1;
delete from test.c1;
set @n=0; insert into test.c1(c1,id) select @N:=@N+1,id from p1;
delete from test.c1;
delete from test.p1;
insert into p1(parent_id) select a from `rows`;
set @n=0; insert into test.c1(c1,id) select @N:=@N+1,id from p1;
delete from test.c1;
--echo -- Normal NR
--exec $_mgm_cmd -e "1 RESTART -n" >> $NDB_TOOLS_OUTPUT
--echo --- Wait for node to stop
--exec $_waiter_cmd --not-started -w1 >> $NDB_TOOLS_OUTPUT
--echo --- Show FKs working
set @n=0; insert into test.c1(c1,id) select @N:=@N+1,id from p1;
delete from test.c1;
set @n=0; insert into test.c1(c1,id) select @N:=@N+1,id from p1;
delete from test.c1;
delete from test.p1;
insert into p1(parent_id) select a from `rows`;
set @n=0; insert into test.c1(c1,id) select @N:=@N+1,id from p1;
delete from test.c1;
--echo --- Startup node again
--exec $_mgm_cmd -e "ALL START" >> $NDB_TOOLS_OUTPUT
--echo --- Wait for node to recover
--exec $_waiter_cmd >> $NDB_TOOLS_OUTPUT
--echo --- Show FKs working
set @n=0; insert into test.c1(c1,id) select @N:=@N+1,id from p1;
delete from test.c1;
set @n=0; insert into test.c1(c1,id) select @N:=@N+1,id from p1;
delete from test.c1;
delete from test.p1;
insert into p1(parent_id) select a from `rows`;
set @n=0; insert into test.c1(c1,id) select @N:=@N+1,id from p1;
delete from test.c1;
--echo -- Initial NR
--exec $_mgm_cmd -e "2 RESTART -n -i" >> $NDB_TOOLS_OUTPUT
--echo --- Wait for node to stop
--exec $_waiter_cmd --not-started -w2 >> $NDB_TOOLS_OUTPUT
--echo --- Show FKs working
set @n=0; insert into test.c1(c1,id) select @N:=@N+1,id from p1;
delete from test.c1;
set @n=0; insert into test.c1(c1,id) select @N:=@N+1,id from p1;
delete from test.c1;
delete from test.p1;
insert into p1(parent_id) select a from `rows`;
set @n=0; insert into test.c1(c1,id) select @N:=@N+1,id from p1;
delete from test.c1;
--echo --- Startup node again
--exec $_mgm_cmd -e "ALL START" >> $NDB_TOOLS_OUTPUT
--echo --- Wait for node to recover
--exec $_waiter_cmd >> $NDB_TOOLS_OUTPUT
--echo --- Show FKs working
set @n=0; insert into test.c1(c1,id) select @N:=@N+1,id from p1;
delete from test.c1;
set @n=0; insert into test.c1(c1,id) select @N:=@N+1,id from p1;
delete from test.c1;
delete from test.p1;
insert into p1(parent_id) select a from `rows`;
set @n=0; insert into test.c1(c1,id) select @N:=@N+1,id from p1;
delete from test.c1;
--echo -- System restart
--exec $_mgm_cmd -e "ALL RESTART -n" >> $NDB_TOOLS_OUTPUT
--echo --- Wait for node to stop
--exec $_waiter_cmd --not-started >> $NDB_TOOLS_OUTPUT
--echo --- Startup nodes again
--exec $_mgm_cmd -e "ALL START" >> $NDB_TOOLS_OUTPUT
--echo --- Wait for nodes to recover
--exec $_waiter_cmd >> $NDB_TOOLS_OUTPUT
--echo --- Wait to establish connection
--source include/ndb_not_readonly.inc
--echo --- Show FKs working
set @n=0; insert into test.c1(c1,id) select @N:=@N+1,id from p1;
delete from test.c1;
set @n=0; insert into test.c1(c1,id) select @N:=@N+1,id from p1;
delete from test.c1;
delete from test.p1;
insert into p1(parent_id) select a from `rows`;
set @n=0; insert into test.c1(c1,id) select @N:=@N+1,id from p1;
delete from test.c1;
delete from test.p1;
drop table test.c2;
drop table test.c1;
drop table test.p1;
drop table test.`rows`;
--remove_file $NDB_TOOLS_OUTPUT