| 1 |
--source include/have_debug.inc |
| 2 |
# Test need restart to make sure ndb_schema table is created the "old" way |
| 3 |
--source include/force_restart.inc |
| 4 |
|
| 5 |
--source connect.inc |
| 6 |
|
| 7 |
# |
| 8 |
# Test ndb_schema table upgrade. |
| 9 |
# |
| 10 |
|
| 11 |
# The variable ndb-schema-dist-upgrade-allowed controls if ndbcluster |
| 12 |
# is allowed to upgrade the ndb_schema table. The variable can only be |
| 13 |
# set when starting MySQL Server. |
| 14 |
# |
| 15 |
# Check that variable is off when test start |
| 16 |
select @@ndb_schema_dist_upgrade_allowed; |
| 17 |
|
| 18 |
# Check that variable is readonly |
| 19 |
--error ER_INCORRECT_GLOBAL_LOCAL_VAR |
| 20 |
set @@ndb_schema_dist_upgrade_allowed = true; |
| 21 |
|
| 22 |
# 1) The MySQL Servers are started with --ndb-schema-dist-upgrade-allowed=false |
| 23 |
# and a special debug flag forcing the ndb_schema table to be created without |
| 24 |
# the new "schema_op_id" column. This will produce warnings in the log file, the |
| 25 |
# MySQL Server will start as usual and allow DDL(although with any |
| 26 |
# functionality that requires the new column disabled) |
| 27 |
|
| 28 |
# Supress warnings in all MySQL Servers, any of them may create the table |
| 29 |
let $i = $NUM_MYSQLDS; |
| 30 |
while($i) |
| 31 |
{ |
| 32 |
connection mysqld$i; |
| 33 |
--disable_query_log |
| 34 |
call mtr.add_suppression("Creating table definition without .* column"); |
| 35 |
call mtr.add_suppression("table need upgrade"); |
| 36 |
--enable_query_log |
| 37 |
dec $i; |
| 38 |
} |
| 39 |
connection default; |
| 40 |
|
| 41 |
# Verify that all the mysqlds detected this as a proper initial start |
| 42 |
--let $assert_select= Detected an initial system start |
| 43 |
--let $assert_only_after= NDB Binlog: Detected server start |
| 44 |
--let $assert_count= 1 |
| 45 |
let $i = $NUM_MYSQLDS; |
| 46 |
while($i) |
| 47 |
{ |
| 48 |
--let $assert_text= Detect initial start in MySQL Server $i |
| 49 |
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.$i.1.err |
| 50 |
--source include/assert_grep.inc |
| 51 |
--dec $i |
| 52 |
} |
| 53 |
|
| 54 |
# 2) Check that DDL works without the "schema_op_id" column |
| 55 |
CREATE TABLE t1( |
| 56 |
pk int not null, |
| 57 |
a varchar(37) not null |
| 58 |
) ENGINE = NDB; |
| 59 |
|
| 60 |
INSERT INTO t1 VALUES(1, "hello"); |
| 61 |
|
| 62 |
ALTER TABLE t1 ADD COLUMN b int NULL DEFAULT 24; |
| 63 |
ALTER TABLE t1 MODIFY COLUMN b int NOT NULL; |
| 64 |
|
| 65 |
SELECT * FROM t1; |
| 66 |
|
| 67 |
DROP TABLE t1; |
| 68 |
|
| 69 |
# 3) Restart the first MySQL Server with ndb-schema-dist-upgrade-allowed=true |
| 70 |
# and pop off the special debug flag. The ndb_schema table will now be upgraded |
| 71 |
# during restart. |
| 72 |
let $param1 = --ndb-schema-dist-upgrade-allowed=true; |
| 73 |
let $param2 = --debug=-d,ndb_schema_skip_create_schema_op_id; |
| 74 |
let $restart_parameters = restart: $param1 $param2; |
| 75 |
let $mysqld_name=mysqld.1.1; |
| 76 |
--source include/restart_mysqld.inc |
| 77 |
|
| 78 |
# Check that variable is on after mysqld restart |
| 79 |
select @@ndb_schema_dist_upgrade_allowed; |
| 80 |
|
| 81 |
# Verify that the binlog setup detected this upgrade as a normal restart |
| 82 |
--let $assert_text= Detect normal system restart in MySQL Server 1 |
| 83 |
--let $assert_select= Detected a normal system restart |
| 84 |
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.1.1.err |
| 85 |
--let $assert_only_after= NDB Binlog: Detected server start |
| 86 |
--let $assert_count= 1 |
| 87 |
--source include/assert_grep.inc |
| 88 |
|
| 89 |
# Supress warning which occurs when restarting |
| 90 |
--disable_query_log ONCE |
| 91 |
call mtr.add_suppression("incident event has been written to the binary log"); |
| 92 |
|
| 93 |
# 4) Check that DDL works _with_ the "schema_op_id" column |
| 94 |
CREATE TABLE t1( |
| 95 |
pk int not null, |
| 96 |
a varchar(37) not null |
| 97 |
) ENGINE = NDB; |
| 98 |
|
| 99 |
INSERT INTO t1 VALUES(1, "hello"); |
| 100 |
|
| 101 |
ALTER TABLE t1 ADD COLUMN b int NULL DEFAULT 24; |
| 102 |
ALTER TABLE t1 MODIFY COLUMN b int NOT NULL; |
| 103 |
|
| 104 |
SELECT * FROM t1; |
| 105 |
|
| 106 |
DROP TABLE t1; |
| 107 |
|
| 108 |
# 5) Check DDL on the other MySQL Servers. The injector thread should handle |
| 109 |
# this gracefully by disabling schema distribution functionality when the |
| 110 |
# ndb_schema table is dropped. Then it will create or set it up again to |
| 111 |
# enable schema distribution functionality without restarting the |
| 112 |
# injector thread. |
| 113 |
|
| 114 |
let $i = $NUM_MYSQLDS; |
| 115 |
while($i > 1) |
| 116 |
{ |
| 117 |
connection mysqld$i; |
| 118 |
|
| 119 |
echo Checking mysqld$i; |
| 120 |
|
| 121 |
# Wait until not readonly after ndb_schema table upgrade |
| 122 |
--source include/ndb_not_readonly.inc |
| 123 |
|
| 124 |
# Verify that this was detected as a normal restart |
| 125 |
--let $assert_text= Detect schema dist setup in MySQL Server $i |
| 126 |
--let $assert_select= Schema distribution setup completed |
| 127 |
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.$i.1.err |
| 128 |
--let $assert_only_after= NDB: The 'mysql.ndb_schema' table has been dropped |
| 129 |
--let $assert_count= 1 |
| 130 |
--source include/assert_grep.inc |
| 131 |
|
| 132 |
CREATE TABLE t1( |
| 133 |
pk int not null, |
| 134 |
a varchar(37) not null |
| 135 |
) ENGINE = NDB; |
| 136 |
|
| 137 |
INSERT INTO t1 VALUES(1, "hello"); |
| 138 |
|
| 139 |
ALTER TABLE t1 ADD COLUMN b int NULL DEFAULT 24; |
| 140 |
ALTER TABLE t1 MODIFY COLUMN b int NOT NULL; |
| 141 |
|
| 142 |
SELECT * FROM t1; |
| 143 |
|
| 144 |
DROP TABLE t1; |
| 145 |
|
| 146 |
dec $i; |
| 147 |
} |
| 148 |
|
| 149 |
connection default; |