| 1 |
# |
| 2 |
# Testing' alter table partition by key' with concurrent dml. |
| 3 |
# |
| 4 |
|
| 5 |
--source include/have_multi_ndb.inc |
| 6 |
|
| 7 |
connect (j1,localhost,root,,test); |
| 8 |
connect (j2,localhost,root,,test); |
| 9 |
connect (j3,localhost,root,,test); |
| 10 |
connect (j4,localhost,root,,test); |
| 11 |
|
| 12 |
connect (ddl,localhost,root,,test); |
| 13 |
|
| 14 |
connection ddl; |
| 15 |
|
| 16 |
create table parent(a int primary key, b int, key(b)) engine=ndb |
| 17 |
comment="NDB_TABLE=PARTITION_BALANCE=FOR_RP_BY_LDM"; |
| 18 |
create table child(a int primary key, b int) engine=ndb |
| 19 |
comment="NDB_TABLE=PARTITION_BALANCE=FOR_RP_BY_LDM"; |
| 20 |
|
| 21 |
insert into parent values (1,1), (2,2), (3,3), (4,4); |
| 22 |
insert into parent select a+4, b+4 from parent; |
| 23 |
insert into parent select a+8, b+8 from parent; |
| 24 |
insert into parent select a+16, b+16 from parent; |
| 25 |
insert into parent select a+32, b+32 from parent; |
| 26 |
insert into parent select a+64, b+64 from parent; |
| 27 |
insert into parent select a+128, b+128 from parent; |
| 28 |
insert into parent select a+256, b+256 from parent; |
| 29 |
insert into parent select a+512, b+512 from parent; |
| 30 |
insert into parent select a+1024, b+1024 from parent; |
| 31 |
insert into parent select a+2048, b+2048 from parent; |
| 32 |
insert into parent select a+4096, b+4096 from parent; |
| 33 |
|
| 34 |
insert into child select * from parent; |
| 35 |
|
| 36 |
connection j1; |
| 37 |
set ndb_join_pushdown = false; |
| 38 |
|
| 39 |
explain |
| 40 |
select count(*) |
| 41 |
from parent join child |
| 42 |
on (parent.b = child.a) |
| 43 |
where parent.b > 5; |
| 44 |
|
| 45 |
--disable_query_log |
| 46 |
delimiter %; |
| 47 |
create procedure queryload (seconds int) |
| 48 |
begin |
| 49 |
set @x=time_to_sec(current_time()) + seconds; |
| 50 |
set ndb_join_pushdown = false; |
| 51 |
repeat |
| 52 |
select count(*) |
| 53 |
from parent join child |
| 54 |
on (parent.b = child.a) |
| 55 |
where parent.b > 5; |
| 56 |
until @x <= time_to_sec(current_time()) |
| 57 |
end repeat; |
| 58 |
end% |
| 59 |
|
| 60 |
delimiter ;% |
| 61 |
--enable_query_log |
| 62 |
|
| 63 |
--echo Starting engines... |
| 64 |
|
| 65 |
connection j1; |
| 66 |
send call queryload(10); |
| 67 |
|
| 68 |
connection j2; |
| 69 |
send call queryload(10); |
| 70 |
|
| 71 |
connection j3; |
| 72 |
send call queryload(10); |
| 73 |
|
| 74 |
connection j4; |
| 75 |
send call queryload(10); |
| 76 |
|
| 77 |
sleep 3; |
| 78 |
|
| 79 |
--echo Beginning alter table child partition by key(a) partitions 4; |
| 80 |
|
| 81 |
# Since server1 is running continuous, parallel DMLs, there is a |
| 82 |
# chance that the required metadata lock might be not available |
| 83 |
# to the server1's participant and it might emit warnings in log. |
| 84 |
connection server1; |
| 85 |
call mtr.add_suppression("Failed to acquire exclusive metadata lock"); |
| 86 |
call mtr.add_suppression("Failed to update table definition in DD"); |
| 87 |
call mtr.add_suppression("Distribution of ALTER TABLE 'test.child' failed"); |
| 88 |
|
| 89 |
connection server2; |
| 90 |
# Also disable the warning sent back to server2 |
| 91 |
--disable_warnings ER_GET_ERRMSG ONCE |
| 92 |
alter table child partition by key(a) partitions 4; |
| 93 |
|
| 94 |
--echo Completed. |
| 95 |
|
| 96 |
connection j1; |
| 97 |
--disable_result_log |
| 98 |
--error 0,ER_NO_SUCH_TABLE,ER_TABLE_DEF_CHANGED |
| 99 |
reap; |
| 100 |
--enable_result_log |
| 101 |
|
| 102 |
connection j2; |
| 103 |
--disable_result_log |
| 104 |
--error 0,ER_NO_SUCH_TABLE,ER_TABLE_DEF_CHANGED |
| 105 |
reap; |
| 106 |
--enable_result_log |
| 107 |
|
| 108 |
connection j3; |
| 109 |
--disable_result_log |
| 110 |
--error 0,ER_NO_SUCH_TABLE,ER_TABLE_DEF_CHANGED |
| 111 |
reap; |
| 112 |
--enable_result_log |
| 113 |
|
| 114 |
connection j4; |
| 115 |
--disable_result_log |
| 116 |
--error 0,ER_NO_SUCH_TABLE,ER_TABLE_DEF_CHANGED |
| 117 |
reap; |
| 118 |
--enable_result_log |
| 119 |
|
| 120 |
connection ddl; |
| 121 |
--echo Ending test. Droping table parent |
| 122 |
drop table parent; |
| 123 |
drop table child; |
| 124 |
drop procedure queryload; |