| 1 |
-- source include/have_multi_ndb.inc |
| 2 |
|
| 3 |
connection server2; |
| 4 |
flush status; |
| 5 |
connection server1; |
| 6 |
flush status; |
| 7 |
|
| 8 |
# Create test tables on server1 |
| 9 |
create table t1 (a int) engine=ndbcluster; |
| 10 |
create table t2 (a int) engine=ndbcluster; |
| 11 |
insert into t1 value (2); |
| 12 |
insert into t2 value (3); |
| 13 |
select * from t1; |
| 14 |
select * from t2; |
| 15 |
show status like 'handler_discover%'; |
| 16 |
|
| 17 |
# Check dropping and recreating table on same server |
| 18 |
connect (con1,localhost,root,,test); |
| 19 |
connect (con2,localhost,root,,test); |
| 20 |
connection con1; |
| 21 |
select * from t1; |
| 22 |
connection con2; |
| 23 |
drop table t1; |
| 24 |
create table t1 (a int) engine=ndbcluster; |
| 25 |
insert into t1 value (2); |
| 26 |
connection con1; |
| 27 |
select * from t1; |
| 28 |
|
| 29 |
# Check dropping and recreating table on different server |
| 30 |
connection server2; |
| 31 |
show status like 'handler_discover%'; |
| 32 |
drop table t1; |
| 33 |
create table t1 (a int) engine=ndbcluster; |
| 34 |
insert into t1 value (2); |
| 35 |
connection server1; |
| 36 |
select * from t1; |
| 37 |
select * from t1; |
| 38 |
|
| 39 |
# Connect to server2 and use the tables from there |
| 40 |
connection server2; |
| 41 |
flush status; |
| 42 |
select * from t1; |
| 43 |
update t1 set a=3 where a=2; |
| 44 |
show status like 'handler_discover%'; |
| 45 |
|
| 46 |
# Create a new table on server2 |
| 47 |
create table t3 (a int not null primary key, b varchar(22), |
| 48 |
c int, last_col text) engine=ndb; |
| 49 |
insert into t3 values(1, 'Hi!', 89, 'Longtext column'); |
| 50 |
create table t4 (pk int primary key, b int) engine=ndb; |
| 51 |
|
| 52 |
# Check that the tables are accessible from server1 |
| 53 |
connection server1; |
| 54 |
select * from t1; |
| 55 |
select * from t3; |
| 56 |
show tables like 't4'; |
| 57 |
show tables; |
| 58 |
|
| 59 |
drop table t1, t2, t3, t4; |
| 60 |
|
| 61 |
# bug#21378 |
| 62 |
connection server1; |
| 63 |
create table t1(c1 int key) ENGINE=InnoDB; |
| 64 |
insert into t1 values(1),(3),(5); |
| 65 |
select * from t1 order by c1; |
| 66 |
|
| 67 |
connection server2; |
| 68 |
show tables; |
| 69 |
create table t1(c1 int key) ENGINE=InnoDB; |
| 70 |
insert into t1 values(100),(344),(533); |
| 71 |
select * from t1 order by c1; |
| 72 |
|
| 73 |
# Suppress errors provoked by the "shadow table" on second mysqld |
| 74 |
--disable_query_log |
| 75 |
call mtr.add_suppression("Local table 'test.t1' .* shadows"); |
| 76 |
call mtr.add_suppression("Failed to update table definition"); |
| 77 |
call mtr.add_suppression("Distribution of ALTER TABLE"); |
| 78 |
--enable_query_log |
| 79 |
|
| 80 |
connection server1; |
| 81 |
replace_regex /Node [0-9]+:/Node <nodeid>/; |
| 82 |
alter table t1 engine=ndb; |
| 83 |
|
| 84 |
connection server2; |
| 85 |
show tables; |
| 86 |
select * from t1 order by c1; |
| 87 |
drop table t1 /* engine = InnoDB */; |
| 88 |
|
| 89 |
connection server1; |
| 90 |
select * from t1 order by c1; |
| 91 |
drop table t1 /* engine = NDB */; |
| 92 |
# End of 4.1 tests |
| 93 |
|
| 94 |
# Check distributed drop of database in 5.1 |
| 95 |
create database db; |
| 96 |
use db; |
| 97 |
create table t1(x int) engine=ndb; |
| 98 |
|
| 99 |
connection server2; |
| 100 |
use db; |
| 101 |
show tables; |
| 102 |
|
| 103 |
connection server1; |
| 104 |
drop database db; |
| 105 |
|
| 106 |
connection server2; |
| 107 |
--error ER_BAD_DB_ERROR |
| 108 |
show tables; |
| 109 |
|
| 110 |
connection server1; |
| 111 |
|
| 112 |
# bug#21495 |
| 113 |
create database db; |
| 114 |
use db; |
| 115 |
create table t1(x int) engine=ndb; |
| 116 |
|
| 117 |
connection server2; |
| 118 |
use db; |
| 119 |
create table t2(x int) engine=innodb; |
| 120 |
show tables; |
| 121 |
|
| 122 |
connection server1; |
| 123 |
replace_regex /Node [0-9]+:/Node <nodeid>/; |
| 124 |
drop database db; |
| 125 |
|
| 126 |
connection server2; |
| 127 |
show tables; |
| 128 |
drop database db; |
| 129 |
|
| 130 |
# |
| 131 |
# bug#31470, ndb table with special characters in name |
| 132 |
# are not discovered correctly |
| 133 |
connection server1; |
| 134 |
use test; |
| 135 |
create table `test`.`t1$EX` |
| 136 |
(server_id int unsigned, |
| 137 |
master_server_id int unsigned, |
| 138 |
master_epoch bigint unsigned, |
| 139 |
count int unsigned, |
| 140 |
primary key(server_id, master_server_id, |
| 141 |
master_epoch, count)) |
| 142 |
engine ndb; |
| 143 |
|
| 144 |
# check that table shows up ok on both servers |
| 145 |
# before bugfix table would not show up on server2 |
| 146 |
--replace_regex /EX/ex/ |
| 147 |
show tables like '%$%'; |
| 148 |
connection server2; |
| 149 |
use test; |
| 150 |
--replace_regex /EX/ex/ |
| 151 |
show tables like '%$%'; |
| 152 |
|
| 153 |
# check cleanup |
| 154 |
drop table `test`.`t1$EX`; |
| 155 |
show tables like '%$%'; |
| 156 |
|
| 157 |
connection server1; |
| 158 |
show tables like '%$%'; |
| 159 |
|
| 160 |
# |
| 161 |
# Bug #42614 Mysql auto locate databases can overwrite frm data. |
| 162 |
# |
| 163 |
connection server1; |
| 164 |
|
| 165 |
create table t1(s char(1)) engine = innodb; |
| 166 |
insert into t1 values ("a"),("b"),("c"); |
| 167 |
|
| 168 |
# Suppress errors provoked by the "shadow table" on first mysqld |
| 169 |
--disable_query_log |
| 170 |
call mtr.add_suppression("Local table 'test.t1' .* shadows"); |
| 171 |
call mtr.add_suppression("Failed to remove table definition"); |
| 172 |
call mtr.add_suppression("Failed to update table definition"); |
| 173 |
call mtr.add_suppression("Distribution of CREATE TABLE"); |
| 174 |
--enable_query_log |
| 175 |
|
| 176 |
connection server2; |
| 177 |
replace_regex /Node [0-9]+:/Node <nodeid>/; |
| 178 |
create table t1(s char(1)) engine = ndb; |
| 179 |
insert into t1 values ("d"),("e"),("f"); |
| 180 |
connection server1; |
| 181 |
## Restart mysqld nodes |
| 182 |
--echo Restarting mysqld |
| 183 |
let $mysqld_name=mysqld.1.1; |
| 184 |
--source include/restart_mysqld.inc |
| 185 |
use test; |
| 186 |
select * from t1 order by s; |
| 187 |
connection server2; |
| 188 |
select * from t1 order by s; |
| 189 |
replace_regex /Node [0-9]+:/Node <nodeid>/; |
| 190 |
drop table t1; |
| 191 |
connection server1; |
| 192 |
select * from t1 order by s; |
| 193 |
connection server2; |
| 194 |
replace_regex /Node [0-9]+:/Node <nodeid>/; |
| 195 |
create table t1(s char(1)) engine = ndb; |
| 196 |
insert into t1 values ("g"),("h"),("i"); |
| 197 |
connection server1; |
| 198 |
show tables; |
| 199 |
select * from t1 order by s; |
| 200 |
|
| 201 |
# |
| 202 |
# Clean-up |
| 203 |
# |
| 204 |
connection server1; |
| 205 |
drop table t1; |
| 206 |
connection server2; |
| 207 |
drop table t1; |
| 208 |
|
| 209 |
# |
| 210 |
--echo Bug 11894966 - second mysqld does not have table after non |
| 211 |
--echo distributed table alter to ndb |
| 212 |
# |
| 213 |
# - only queries with "autodiscover" see the new table |
| 214 |
# on second mysqld since schema distribution does not |
| 215 |
# create the table on second mysqld(at least when !ndb_binlog_running) |
| 216 |
# |
| 217 |
connection server1; |
| 218 |
|
| 219 |
# Create table t1 in innodb |
| 220 |
create table t1(a int) engine innodb; |
| 221 |
insert into t1 values(37); |
| 222 |
|
| 223 |
# Alter t1 into ndb |
| 224 |
alter table t1 engine ndb; |
| 225 |
|
| 226 |
# Switch to other mysqld |
| 227 |
connection server2; |
| 228 |
|
| 229 |
# Check that truncate works on second mysqld |
| 230 |
# (didn't work before fix) |
| 231 |
truncate t1; |
| 232 |
|
| 233 |
# Cleanup |
| 234 |
drop table t1; |
| 235 |
connection server1; |
| 236 |
|
| 237 |
# |
| 238 |
# Bug#14798043 DROP DATABASE PERFORMANCE_SCHEMA DROPS IT ON ALL SQL NODES |
| 239 |
# Check that local tables in system database are not dropped remotely |
| 240 |
|
| 241 |
create table mysql.dummy(a int primary key, b int) engine=innodb; |
| 242 |
connection server2; |
| 243 |
create table mysql.dummy(a int primary key, b int) engine=innodb; |
| 244 |
connection server1; |
| 245 |
drop table mysql.dummy; |
| 246 |
connection server2; |
| 247 |
show create table mysql.dummy; |
| 248 |
drop table mysql.dummy; |
| 249 |
|
| 250 |
# |
| 251 |
# #Bug#23553267 DEADLOCK WHEN MDL_EXCLUSIVE ACQUIRES A GSL LOCK |
| 252 |
# |
| 253 |
# Multiple mysqlds may be involved in a deadlock when |
| 254 |
# a mysql upgrading an MDL_INTENTIONAL_EXCLUSIVE(IX) to MDL_EXCLUSIV |
| 255 |
# require a GSL to be taken. At the same time the GSL may be |
| 256 |
# held a schema distr. op. which blocks on the above IX when |
| 257 |
# trying to acquire an MDL_EXCLUSIVE. |
| 258 |
# |
| 259 |
--connection server1 |
| 260 |
CREATE DATABASE tmp_db; |
| 261 |
|
| 262 |
--connection server2 |
| 263 |
--echo Let server2 create the table tmp_db.t1 in the background. |
| 264 |
send CREATE TABLE tmp_db.t1 (k int primary key) ENGINE NDB; |
| 265 |
|
| 266 |
--connection server1 |
| 267 |
--echo Attempt to recreate 'tmp_db', expect 'EXISTS' failure - Not MDL deadlocks |
| 268 |
CREATE DATABASE IF NOT EXISTS tmp_db; |
| 269 |
|
| 270 |
--connection server2 |
| 271 |
--echo Wait for server2 table creation to complete. |
| 272 |
reap; |
| 273 |
Select count(*) from tmp_db.t1; |
| 274 |
|
| 275 |
--connection server1 |
| 276 |
DROP TABLE tmp_db.t1; |
| 277 |
DROP DATABASE tmp_db; |
| 278 |
|