1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374
|
-- 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;
|