| 1 |
-- source include/have_multi_ndb.inc |
| 2 |
|
| 3 |
# operations allowed while cluster is in single user mode |
| 4 |
|
| 5 |
--connection server1 |
| 6 |
--let $node_id= `SHOW STATUS LIKE 'Ndb_cluster_node_id'` |
| 7 |
--disable_query_log |
| 8 |
--eval set @node_id= SUBSTRING('$node_id', 20)+0 |
| 9 |
--enable_query_log |
| 10 |
--let $node_id= `SELECT @node_id` |
| 11 |
--exec $NDB_MGM -e "enter single user mode $node_id" >> $NDB_TOOLS_OUTPUT |
| 12 |
--exec $NDB_WAITER --single-user |
| 13 |
|
| 14 |
# verify that we are indeed in single user mode |
| 15 |
# and test that some operations give correct errors |
| 16 |
--connection server2 |
| 17 |
--error ER_CANT_CREATE_TABLE |
| 18 |
create table t1 (a int key, b int unique, c int) engine ndb; |
| 19 |
show warnings; |
| 20 |
# Bug #27712 Single user mode. Creating logfile group and tablespace is allowed |
| 21 |
# - before bug fix these would succeed |
| 22 |
--error ER_CREATE_FILEGROUP_FAILED |
| 23 |
CREATE LOGFILE GROUP lg1 |
| 24 |
ADD UNDOFILE 'undofile.dat' |
| 25 |
INITIAL_SIZE 16M |
| 26 |
UNDO_BUFFER_SIZE = 1M |
| 27 |
ENGINE=NDB; |
| 28 |
show warnings; |
| 29 |
|
| 30 |
# test some sql on first mysqld |
| 31 |
--connection server1 |
| 32 |
create table t1 (a int key, b int unique, c int) engine ndb; |
| 33 |
# Check that we can create logfile group |
| 34 |
CREATE LOGFILE GROUP lg1 |
| 35 |
ADD UNDOFILE 'undofile.dat' |
| 36 |
INITIAL_SIZE 16M |
| 37 |
UNDO_BUFFER_SIZE = 1M |
| 38 |
ENGINE=NDB; |
| 39 |
--connection server2 |
| 40 |
--error ER_CREATE_FILEGROUP_FAILED |
| 41 |
CREATE TABLESPACE ts1 |
| 42 |
ADD DATAFILE 'datafile.dat' |
| 43 |
USE LOGFILE GROUP lg1 |
| 44 |
INITIAL_SIZE 12M |
| 45 |
ENGINE NDB; |
| 46 |
show warnings; |
| 47 |
--error ER_DROP_FILEGROUP_FAILED |
| 48 |
DROP LOGFILE GROUP lg1 |
| 49 |
ENGINE =NDB; |
| 50 |
show warnings; |
| 51 |
--connection server1 |
| 52 |
CREATE TABLESPACE ts1 |
| 53 |
ADD DATAFILE 'datafile.dat' |
| 54 |
USE LOGFILE GROUP lg1 |
| 55 |
INITIAL_SIZE 12M |
| 56 |
ENGINE NDB; |
| 57 |
--connection server2 |
| 58 |
--error ER_ALTER_FILEGROUP_FAILED |
| 59 |
ALTER TABLESPACE ts1 |
| 60 |
DROP DATAFILE 'datafile.dat'; |
| 61 |
show warnings; |
| 62 |
--connection server1 |
| 63 |
ALTER TABLESPACE ts1 |
| 64 |
DROP DATAFILE 'datafile.dat'; |
| 65 |
--connection server2 |
| 66 |
--error ER_DROP_FILEGROUP_FAILED |
| 67 |
DROP TABLESPACE ts1; |
| 68 |
show warnings; |
| 69 |
--connection server1 |
| 70 |
DROP TABLESPACE ts1; |
| 71 |
DROP LOGFILE GROUP lg1 |
| 72 |
ENGINE =NDB; |
| 73 |
insert into t1 values (1,1,0),(2,2,0),(3,3,0),(4,4,0),(5,5,0),(6,6,0),(7,7,0),(8,8,0),(9,9,0),(10,10,0); |
| 74 |
create table t2 as select * from t1; |
| 75 |
# read with pk |
| 76 |
select * from t1 where a = 1; |
| 77 |
# read with unique index |
| 78 |
select * from t1 where b = 4; |
| 79 |
# read with ordered index |
| 80 |
select * from t1 where a > 4 order by a; |
| 81 |
# update with pk |
| 82 |
update t1 set b=102 where a = 2; |
| 83 |
# update with unique index |
| 84 |
update t1 set b=103 where b = 3; |
| 85 |
# update with full table scan |
| 86 |
update t1 set b=b+100; |
| 87 |
# update with ordered insex scan |
| 88 |
update t1 set b=b+100 where a > 7; |
| 89 |
# delete with full table scan |
| 90 |
delete from t1; |
| 91 |
insert into t1 select * from t2; |
| 92 |
# Bug #27710 Creating unique index fails during single user mode |
| 93 |
# - prior to bugfix this would fail |
| 94 |
create unique index new_index on t1 (b,c); |
| 95 |
|
| 96 |
|
| 97 |
# Bug#16275500, Check if `ndb_mgm> SHOW` show Api node in single user mode. |
| 98 |
|
| 99 |
--replace_regex /mysql(.*?)(?=, )/MYSQL_VERSION NDB_VERSION/ /mysql(.*?)(?=\))/MYSQL_VERSION NDB_VERSION/ /@127.0.0.1/LOCALHOST/ /@::1/LOCALHOST/ |
| 100 |
--exec $NDB_MGM -e show; |
| 101 |
|
| 102 |
drop table t2; |
| 103 |
|
| 104 |
# test some sql on other mysqld |
| 105 |
--connection server2 |
| 106 |
--error ER_ENGINE_CANT_DROP_TABLE |
| 107 |
drop table t1; |
| 108 |
--error ER_GET_ERRMSG |
| 109 |
create index new_index_fail on t1 (c); |
| 110 |
--error ER_GET_ERRMSG |
| 111 |
insert into t1 values (21,21,0),(22,22,0),(23,23,0),(24,24,0),(25,25,0),(26,26,0),(27,27,0),(28,28,0),(29,29,0),(210,210,0); |
| 112 |
--error ER_GET_ERRMSG |
| 113 |
select * from t1 where a = 1; |
| 114 |
--error ER_GET_ERRMSG |
| 115 |
select * from t1 where b = 4; |
| 116 |
--error ER_GET_ERRMSG |
| 117 |
update t1 set b=102 where a = 2; |
| 118 |
--error ER_GET_ERRMSG |
| 119 |
update t1 set b=103 where b = 3; |
| 120 |
--error ER_GET_ERRMSG |
| 121 |
update t1 set b=b+100; |
| 122 |
--error ER_GET_ERRMSG |
| 123 |
update t1 set b=b+100 where a > 7; |
| 124 |
|
| 125 |
--exec $NDB_MGM -e "exit single user mode" >> $NDB_TOOLS_OUTPUT |
| 126 |
--exec $NDB_WAITER |
| 127 |
|
| 128 |
# |
| 129 |
# we should be able to run transaction while in single user mode |
| 130 |
# |
| 131 |
--connection server1 |
| 132 |
BEGIN; |
| 133 |
update t1 set b=b+100 where a=1; |
| 134 |
|
| 135 |
--connection server2 |
| 136 |
BEGIN; |
| 137 |
update t1 set b=b+100 where a=2; |
| 138 |
|
| 139 |
# enter single user mode |
| 140 |
--exec $NDB_MGM -e "enter single user mode $node_id" >> $NDB_TOOLS_OUTPUT |
| 141 |
--exec $NDB_WAITER --single-user |
| 142 |
|
| 143 |
--connection server1 |
| 144 |
update t1 set b=b+100 where a=3; |
| 145 |
COMMIT; |
| 146 |
|
| 147 |
# while on other mysqld it should be aborted |
| 148 |
--connection server2 |
| 149 |
--error ER_GET_ERRMSG |
| 150 |
update t1 set b=b+100 where a=4; |
| 151 |
ROLLBACK; |
| 152 |
|
| 153 |
# Bug #25275 SINGLE USER MODE prevents ALTER on non-ndb |
| 154 |
# tables for other mysqld nodes |
| 155 |
--connection server2 |
| 156 |
create table t2 (a int) engine myisam; |
| 157 |
alter table t2 add column (b int); |
| 158 |
|
| 159 |
# exit single user mode |
| 160 |
--exec $NDB_MGM -e "exit single user mode" >> $NDB_TOOLS_OUTPUT |
| 161 |
--exec $NDB_WAITER |
| 162 |
|
| 163 |
# cleanup |
| 164 |
--connection server2 |
| 165 |
drop table t2; |
| 166 |
--connection server1 |
| 167 |
drop table t1; |
| 168 |
|
| 169 |
# End of 5.0 tests |
| 170 |
|
| 171 |
--remove_file $NDB_TOOLS_OUTPUT |