| 1 |
--source include/have_ndb.inc |
| 2 |
|
| 3 |
--echo Testing the behaviour of ANALYZE TABLE before and |
| 4 |
--echo after table reorganisation, and then during subsequent |
| 5 |
--echo node restarts |
| 6 |
--echo |
| 7 |
|
| 8 |
--echo Create initial table |
| 9 |
create table t_offset(a int primary key) engine=ndb; |
| 10 |
create table t_orig(id int PRIMARY KEY, d1 bigint, d2 int, key(d1), key(d2)) engine=ndb; |
| 11 |
|
| 12 |
--echo Put some data in with different key distributions |
| 13 |
--disable_result_log |
| 14 |
--disable_query_log |
| 15 |
insert into t_orig values (1,1,1), (2,1,1); |
| 16 |
|
| 17 |
let $TOTROWS=2000; |
| 18 |
let $ROWS=$TOTROWS; |
| 19 |
set @a:=1; |
| 20 |
set @b:=1; |
| 21 |
set @c:=@a+@b; |
| 22 |
|
| 23 |
while ($ROWS) |
| 24 |
{ |
| 25 |
# d1 has fibonacci based distribution |
| 26 |
# d2 has low cardinality distribution |
| 27 |
--eval insert into t_orig values (3+($TOTROWS-$ROWS), @a+@b, ($ROWS % 2)); |
| 28 |
set @a:=@b % (2 << 32); |
| 29 |
set @b:=@c % (2 << 32); |
| 30 |
set @c:=@a+@b; |
| 31 |
--dec $ROWS |
| 32 |
} |
| 33 |
|
| 34 |
#select * from t_orig order by id; |
| 35 |
--enable_query_log |
| 36 |
--enable_result_log |
| 37 |
|
| 38 |
--echo Analyze the indices on the table |
| 39 |
analyze table test.t_orig; |
| 40 |
|
| 41 |
--echo Add the nodes |
| 42 |
--exec $NDB_MGM -e "create nodegroup 3,4" >> $NDB_TOOLS_OUTPUT |
| 43 |
|
| 44 |
--echo Create a table with the new topology |
| 45 |
create table t_new(id int PRIMARY KEY, d1 bigint, d2 int, key(d1), key(d2)) engine=ndb; |
| 46 |
|
| 47 |
--echo Insert data into it |
| 48 |
insert into t_new select * from t_orig; |
| 49 |
|
| 50 |
--echo Analyze the new table |
| 51 |
analyze table test.t_new; |
| 52 |
|
| 53 |
--echo Reorganize the original table across the new set of nodes |
| 54 |
alter table t_orig reorganize partition; |
| 55 |
|
| 56 |
--echo Check ANALYZE succeeds after table reorganization |
| 57 |
analyze table t_orig; |
| 58 |
analyze table t_new; |
| 59 |
|
| 60 |
--echo Restart data nodes, checking that ANALYZE TABLE |
| 61 |
--echo succeeds in all intermediate states |
| 62 |
# |
| 63 |
# Restarting data nodes in ascending or descending order has |
| 64 |
# an effect on outcomes |
| 65 |
# |
| 66 |
let $ascending=1; |
| 67 |
let $nodes = 4; |
| 68 |
let $cnt = $nodes; |
| 69 |
while ($cnt) |
| 70 |
{ |
| 71 |
let $nid=$cnt; # descending |
| 72 |
if ($ascending) |
| 73 |
{ |
| 74 |
--disable_query_log |
| 75 |
--disable_result_log |
| 76 |
let $nid=query_get_value("select 1 + $nodes-$cnt as c", c, 1); # low to high |
| 77 |
--enable_query_log |
| 78 |
--enable_result_log |
| 79 |
} |
| 80 |
--echo Restart node $nid |
| 81 |
--exec $NDB_MGM --execute "$nid restart -n" >> $NDB_TOOLS_OUTPUT |
| 82 |
--exec $NDB_WAITER --wait-nodes=$nid --not-started |
| 83 |
--exec $NDB_MGM --execute "$nid start" >> $NDB_TOOLS_OUTPUT |
| 84 |
--exec $NDB_WAITER --wait-nodes=$nid |
| 85 |
--echo Restart finished |
| 86 |
|
| 87 |
--echo Analyze the tables |
| 88 |
analyze table test.t_orig; |
| 89 |
analyze table test.t_new; |
| 90 |
|
| 91 |
--dec $cnt |
| 92 |
} |
| 93 |
|
| 94 |
--echo Cleanup |
| 95 |
drop table t_offset,t_orig,t_new; |
| 96 |
|
| 97 |
## Drop nodegroup with "new" nodes |
| 98 |
--exec $NDB_MGM -e "drop nodegroup 1" >> $NDB_TOOLS_OUTPUT |
| 99 |
|
| 100 |
--remove_file $NDB_TOOLS_OUTPUT |