ndb_single_user.test 3.21 KB
Newer Older
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
-- source include/have_ndb.inc
-- source include/have_multi_ndb.inc
-- source include/ndb_default_cluster.inc
-- source include/not_embedded.inc

--disable_warnings
use test;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
--enable_warnings

# operations allowed while cluster is in single user mode

--connection server1
--let $node_id= `SHOW STATUS LIKE 'Ndb_cluster_node_id'`
--disable_query_log
--eval set @node_id= SUBSTRING('$node_id', 20)+0
--enable_query_log
--let $node_id= `SELECT @node_id`
--exec $NDB_MGM --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -e "enter single user mode $node_id" >> $NDB_TOOLS_OUTPUT
--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" --single-user >> $NDB_TOOLS_OUTPUT

# verify that we are indeed in single user mode
--connection server2
--error 1005
create table t1 (a int key, b int unique, c int) engine ndb;

# test some sql on first mysqld
--connection server1
create table t1 (a int key, b int unique, c int) engine ndb;
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);
create table t2 as select * from t1;
# read with pk
select * from t1 where a = 1;
# read with unique index
select * from t1 where b = 4;
# read with ordered index
select * from t1 where a > 4 order by a;
# update with pk
update t1 set b=102 where a = 2;
# update with unique index
update t1 set b=103 where b = 3;
# update with full table scan
update t1 set b=b+100;
# update with ordered insex scan
update t1 set b=b+100 where a > 7;
# delete with full table scan
delete from t1;
insert into t1 select * from t2;

# test some sql on other mysqld
--connection server2
--error 1051
drop table t1;
54
--error 1296
55
create index new_index on t1 (c);
56
--error 1296
57
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);
58
--error 1296
59
select * from t1 where a = 1;
60
--error 1296
61
select * from t1 where b = 4;
62
--error 1296
63
update t1 set b=102 where a = 2;
64
--error 1296
65
update t1 set b=103 where b = 3;
66
--error 1296
67
update t1 set b=b+100;
68
--error 1296
69 70 71 72 73
update t1 set b=b+100 where a > 7;

--exec $NDB_MGM --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -e "exit single user mode" >> $NDB_TOOLS_OUTPUT
--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults >> $NDB_TOOLS_OUTPUT

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
#
# we should be able to run transaction while in single user mode
#
--connection server1
BEGIN;
update t1 set b=b+100 where a=1;

--connection server2
BEGIN;
update t1 set b=b+100 where a=2;

# enter single user mode
--exec $NDB_MGM --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -e "enter single user mode $node_id" >> $NDB_TOOLS_OUTPUT
--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" --single-user >> $NDB_TOOLS_OUTPUT

--connection server1
update t1 set b=b+100 where a=3;
COMMIT;

# while on other mysqld it should be aborted
--connection server2
--error 1296
update t1 set b=b+100 where a=4;
--error 1296
COMMIT;

--exec $NDB_MGM --no-defaults --ndb-connectstring="localhost:$NDBCLUSTER_PORT" -e "exit single user mode" >> $NDB_TOOLS_OUTPUT
--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults >> $NDB_TOOLS_OUTPUT

103 104 105
# cleanup
--connection server1
drop table t1;