| 1 |
--echo Check row count |
| 2 |
select count(1) from test.t1 into @row_count; |
| 3 |
select @row_count; |
| 4 |
|
| 5 |
|
| 6 |
--echo Check Physical row count against expected |
| 7 |
select sum(fixed_elem_count) from ndbinfo.memory_per_fragment where fq_name='test/def/t1' into @sum; |
| 8 |
set @diff = (@row_count * @prpr) - @sum; |
| 9 |
select floor(@row_count * @prpr) as expected_phys_rows, |
| 10 |
@sum as actual_phys_rows, |
| 11 |
@diff as diff; |
| 12 |
|
| 13 |
--let $d=query_get_value(select @diff as d, d, 1) |
| 14 |
|
| 15 |
if ($d) |
| 16 |
{ |
| 17 |
--echo Show actual fragments |
| 18 |
select * from ndbinfo.memory_per_fragment |
| 19 |
where fq_name='test/def/t1' |
| 20 |
order by |
| 21 |
node_id, fragment_num; |
| 22 |
--die Physical vs Logical row count error |
| 23 |
} |
| 24 |
|
| 25 |
|
| 26 |
--echo Check UI physical row count against expected |
| 27 |
select sum(fixed_elem_count) from ndbinfo.memory_per_fragment where parent_fq_name='test/def/t1' and fq_name like '%/c$unique' into @sum; |
| 28 |
set @diff = (@row_count * @prpr) - @sum; |
| 29 |
select floor(@row_count * @prpr) as expected_phys_rows, |
| 30 |
@sum as actual_phys_rows, |
| 31 |
@diff as diff; |
| 32 |
|
| 33 |
#--echo Show actual fragments |
| 34 |
#select * from ndbinfo.memory_per_fragment |
| 35 |
# where fq_name='test/def/t1' |
| 36 |
# order by |
| 37 |
# node_id, fragment_num; |
| 38 |
# |
| 39 |
## indices |
| 40 |
#select * from ndbinfo.memory_per_fragment |
| 41 |
# where parent_fq_name='test/def/t1' |
| 42 |
# order by |
| 43 |
# node_id, fragment_num; |
| 44 |
|
| 45 |
#--echo Show fragment balance |
| 46 |
#select avg(fixed_elem_count), |
| 47 |
# std(fixed_elem_count), |
| 48 |
# min(fixed_elem_count), |
| 49 |
# max(fixed_elem_count) |
| 50 |
# from ndbinfo.memory_per_fragment |
| 51 |
# where fq_name='test/def/t1'; |
| 52 |
|
| 53 |
--echo Delete some data |
| 54 |
delete from test.t1 limit 512; |
| 55 |
|
| 56 |
--echo Show new logical row count |
| 57 |
select count(1) from test.t1 into @new_row_count; |
| 58 |
select @new_row_count; |
| 59 |
|
| 60 |
#--echo Show fragment balance |
| 61 |
#select avg(fixed_elem_count), |
| 62 |
# std(fixed_elem_count), |
| 63 |
# min(fixed_elem_count), |
| 64 |
# max(fixed_elem_count) |
| 65 |
# from ndbinfo.memory_per_fragment |
| 66 |
# where fq_name='test/def/t1'; |
| 67 |
|
| 68 |
--echo Check new Physical row count against expected |
| 69 |
select sum(fixed_elem_count) from ndbinfo.memory_per_fragment where fq_name='test/def/t1' into @sum; |
| 70 |
set @diff = (@new_row_count * @prpr) - @sum; |
| 71 |
select floor(@new_row_count * @prpr) as expected_phys_rows, |
| 72 |
@sum as actual_phys_rows, |
| 73 |
@diff as diff; |
| 74 |
|
| 75 |
--let $d=query_get_value(select @diff as d, d, 1) |
| 76 |
|
| 77 |
if ($d) |
| 78 |
{ |
| 79 |
--echo Show actual fragments |
| 80 |
select * from ndbinfo.memory_per_fragment |
| 81 |
where fq_name='test/def/t1' |
| 82 |
order by |
| 83 |
node_id, fragment_num; |
| 84 |
--die Physical vs Logical row count error |
| 85 |
} |
| 86 |
|
| 87 |
|
| 88 |
--echo Check UI physical row count against expected |
| 89 |
select sum(fixed_elem_count) from ndbinfo.memory_per_fragment where parent_fq_name='test/def/t1' and fq_name like '%/c$unique' into @sum; |
| 90 |
set @diff = (@new_row_count * @prpr) - @sum; |
| 91 |
select floor(@new_row_count * @prpr) as expected_phys_rows, |
| 92 |
@sum as actual_phys_rows, |
| 93 |
@diff as diff; |
| 94 |
--disable_query_log |
| 95 |
--disable_result_log |
| 96 |
select @m:=max(a) from test.t1; |
| 97 |
|
| 98 |
--echo Insert some data |
| 99 |
insert into test.t1 select a+@m, b+@m, c+@m, d+@m from test.t1 limit 800; |
| 100 |
--enable_query_log |
| 101 |
--enable_result_log |
| 102 |
|
| 103 |
--echo Show new logical row count |
| 104 |
select count(1) from test.t1 into @new_row_count; |
| 105 |
select @new_row_count; |
| 106 |
|
| 107 |
--echo Check new Physical row count against expected |
| 108 |
select sum(fixed_elem_count) from ndbinfo.memory_per_fragment where fq_name='test/def/t1' into @sum; |
| 109 |
set @diff = (@new_row_count * @prpr) - @sum; |
| 110 |
select floor(@new_row_count * @prpr) as expected_phys_rows, |
| 111 |
@sum as actual_phys_rows, |
| 112 |
@diff as diff; |
| 113 |
|
| 114 |
--let $d=query_get_value(select @diff as d, d, 1) |
| 115 |
|
| 116 |
if ($d) |
| 117 |
{ |
| 118 |
--echo Show actual fragments |
| 119 |
select * from ndbinfo.memory_per_fragment |
| 120 |
where fq_name='test/def/t1' |
| 121 |
order by |
| 122 |
node_id, fragment_num; |
| 123 |
--die Physical vs Logical row count error |
| 124 |
} |
| 125 |
|
| 126 |
|
| 127 |
--echo Check UI physical row count against expected |
| 128 |
select sum(fixed_elem_count) from ndbinfo.memory_per_fragment where parent_fq_name='test/def/t1' and fq_name like '%/c$unique' into @sum; |
| 129 |
set @diff = (@new_row_count * @prpr) - @sum; |
| 130 |
select floor(@new_row_count * @prpr) as expected_phys_rows, |
| 131 |
@sum as actual_phys_rows, |
| 132 |
@diff as diff; |
| 133 |
|
| 134 |
--echo Show read-locality at all data nodes |
| 135 |
|
| 136 |
# Handy table to allow cluster_transactions to show |
| 137 |
# the TC node chosen for each iteration |
| 138 |
create table test.t2(a int primary key) engine=ndb; |
| 139 |
insert into test.t2 values (1); |
| 140 |
|
| 141 |
create table nodes(id int primary key); |
| 142 |
|
| 143 |
# Enough iterations to hopefully run on each node |
| 144 |
--let $ITERATIONS=20 |
| 145 |
|
| 146 |
--disable_query_log |
| 147 |
--disable_result_log |
| 148 |
|
| 149 |
while($ITERATIONS) |
| 150 |
{ |
| 151 |
begin; |
| 152 |
select * from mysql.ndb_apply_status; |
| 153 |
select * from test.t2 for update; |
| 154 |
|
| 155 |
# --echo Error insert to ensure that TC requests are purely local |
| 156 |
--exec $NDB_MGM -e "ALL ERROR 8083" >> $NDB_TOOLS_OUTPUT |
| 157 |
# PK |
| 158 |
select * from test.t1 where a = 100000; |
| 159 |
|
| 160 |
# STILL DISABLED as UK read is not always local |
| 161 |
# UK |
| 162 |
#select * from test.t1 where c= 100000; |
| 163 |
|
| 164 |
# PK OI scan |
| 165 |
select * from test.t1 where a > 100000; |
| 166 |
|
| 167 |
# Secondary OI scan |
| 168 |
select * from test.t1 where d > 100000; |
| 169 |
|
| 170 |
# Pushed PK -> PK join |
| 171 |
select * |
| 172 |
from test.t1 a join test.t1 b |
| 173 |
on a.d = b.a |
| 174 |
where a.a=2; |
| 175 |
|
| 176 |
# Pushed PK -> UK join |
| 177 |
select * |
| 178 |
from test.t1 a join test.t1 b |
| 179 |
on a.d = b.c |
| 180 |
where a.a=2; |
| 181 |
|
| 182 |
# Pushed UK -> UK join |
| 183 |
select * |
| 184 |
from test.t1 a join test.t1 b |
| 185 |
on a.d = b.c |
| 186 |
where a.c=2; |
| 187 |
|
| 188 |
# Pushed OI -> PK join |
| 189 |
select * |
| 190 |
from test.t1 a join test.t1 b |
| 191 |
on a.b = b.a |
| 192 |
where a.d < 5; |
| 193 |
|
| 194 |
# Pushed UI -> OI join |
| 195 |
select * |
| 196 |
from test.t1 a join test.t1 b |
| 197 |
on a.b = b.c |
| 198 |
where a.a=2; |
| 199 |
|
| 200 |
# Pushed OI -> OI join |
| 201 |
select * |
| 202 |
from test.t1 a join test.t1 b |
| 203 |
on b.d = a.c |
| 204 |
where a.d < 6; |
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
--exec $NDB_MGM -e "ALL ERROR 0" >> $NDB_TOOLS_OUTPUT |
| 209 |
replace into nodes select node_id from ndbinfo.cluster_transactions; |
| 210 |
commit; |
| 211 |
--dec $ITERATIONS |
| 212 |
} |
| 213 |
--enable_query_log |
| 214 |
--enable_result_log |
| 215 |
|
| 216 |
--echo Expect that the transaction ran on all 4 nodes : |
| 217 |
select count(1) from nodes; |
| 218 |
drop table nodes; |
| 219 |
|
| 220 |
drop table test.t2; |