Skip to content

Commit b4975b2

Browse files
author
Jan Wedvik
committed
This is a fix for deviations in statistics counter values that occur when running ndb_join_pushdown.test on
big-endian (Sparc) and with Valgrind. This fix does two things: * Some ndb$info counters are removed from the test, because their values depend on endian-dependent key hashing. This includes READS_NOT_FOUND, LOCAL_READS_SENT, REMOTE_READS_SENT and SCAN_ROWS_RETURNED. * Ndb_scan_count was sometimes off by one when testing with Valgrind, possibly because table statistics was refreshed at unpredictable intervals. Instead of testing the exact value of Ndb_scan_count, the test will fail if Ndb_scan_count deviates from the expected values by more than 10%.
1 parent 7926cf1 commit b4975b2

File tree

2 files changed

+11
-70
lines changed

2 files changed

+11
-70
lines changed

mysql-test/suite/ndb/r/ndb_join_pushdown.result

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ select counter_name, sum(val) as val
44
from ndbinfo.counters
55
where block_name='DBSPJ'
66
group by counter_name;
7-
create temporary table spj_save_counts like spj_counts_at_startup;
8-
insert into spj_save_counts values ('SCAN_ROWS_RETURNED', 0);
97
set @save_ndb_join_pushdown = @@session.ndb_join_pushdown;
108
set ndb_join_pushdown = true;
119
create table t1 (
@@ -2060,7 +2058,6 @@ count(*)
20602058
304
20612059
drop table tx;
20622060
alter table t1 partition by key(a);
2063-
update spj_save_counts set val = (select sum(val) from ndbinfo.counters where block_name='DBSPJ' and counter_name='SCAN_ROWS_RETURNED') where counter_name='SCAN_ROWS_RETURNED';
20642061
explain select count(*) from t1
20652062
join t1 as t2 on t2.a = t1.c
20662063
join t1 as t3 on t3.a = t1.c;
@@ -2092,7 +2089,6 @@ join t1 as x2 on x2.a = x1.c and x1.b < 2
20922089
join t1 as x3 on x3.a = x1.c;
20932090
count(*)
20942091
20000
2095-
update spj_counts_at_startup set val = val + (select sum(val) from ndbinfo.counters where block_name='DBSPJ' and counter_name='SCAN_ROWS_RETURNED') - (select val from spj_save_counts where counter_name='SCAN_ROWS_RETURNED') where counter_name='SCAN_ROWS_RETURNED';
20962092
drop table t1;
20972093
drop table tx;
20982094
create table t1 (a int, b int, primary key(a) using hash) engine = ndb;
@@ -4331,7 +4327,6 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
43314327
Warnings:
43324328
Note 9999 Can't push table 'x3' as child of 'x1', outer join of scan-child not implemented
43334329
Note 1003 select straight_join `test`.`x1`.`pk` AS `pk`,`test`.`x1`.`u` AS `u`,`test`.`x1`.`a` AS `a`,`test`.`x1`.`b` AS `b`,`test`.`x2`.`pk` AS `pk`,`test`.`x2`.`u` AS `u`,`test`.`x2`.`a` AS `a`,`test`.`x2`.`b` AS `b`,`test`.`x3`.`pk` AS `pk`,`test`.`x3`.`u` AS `u`,`test`.`x3`.`a` AS `a`,`test`.`x3`.`b` AS `b` from `test`.`t1` `x1` left join (`test`.`t1` `x2` join `test`.`t1` `x3`) on(((`test`.`x2`.`pk` = `test`.`x1`.`a`) and (`test`.`x3`.`b` = `test`.`x2`.`a`))) where 1
4334-
update spj_save_counts set val = (select sum(val) from ndbinfo.counters where block_name='DBSPJ' and counter_name='SCAN_ROWS_RETURNED') where counter_name='SCAN_ROWS_RETURNED';
43354330
explain extended select straight_join count(*) from t1 as x1
43364331
join t1 as x2 on x2.b = x1.a
43374332
join t1 as x3 on x3.b = x1.b;
@@ -4381,7 +4376,6 @@ join t1 as x7 on x7.b = x1.a
43814376
where x3.a < x2.pk and x4.a < x3.pk;
43824377
count(*)
43834378
632736
4384-
update spj_counts_at_startup set val = val + (select sum(val) from ndbinfo.counters where block_name='DBSPJ' and counter_name='SCAN_ROWS_RETURNED') - (select val from spj_save_counts where counter_name='SCAN_ROWS_RETURNED') where counter_name='SCAN_ROWS_RETURNED';
43854379
explain extended select straight_join count(*) from t1 as x1
43864380
left join t1 as x2 on x2.b = x1.a
43874381
join t1 as x3 on x3.b = x1.b;
@@ -4426,7 +4420,6 @@ join t1 as x2 on x2.b = x1.a
44264420
left join t1 as x3 on x3.b = x1.b;
44274421
count(*)
44284422
2028
4429-
update spj_save_counts set val = (select sum(val) from ndbinfo.counters where block_name='DBSPJ' and counter_name='SCAN_ROWS_RETURNED') where counter_name='SCAN_ROWS_RETURNED';
44304423
explain extended
44314424
select straight_join count(*) from t1 as x1
44324425
join t1 as x2 on x2.b = x1.a
@@ -4450,7 +4443,6 @@ join t1 as x2 on x2.b = x1.a
44504443
join t1 as x3 on x3.pk = x1.a join t1 as x4 on x4.b = x3.a;
44514444
count(*)
44524445
2028
4453-
update spj_counts_at_startup set val = val + (select sum(val) from ndbinfo.counters where block_name='DBSPJ' and counter_name='SCAN_ROWS_RETURNED') - (select val from spj_save_counts where counter_name='SCAN_ROWS_RETURNED') where counter_name='SCAN_ROWS_RETURNED';
44544446
explain extended select straight_join count(*) from t1 as x1
44554447
left join t1 as x3 on x3.b = x1.a
44564448
join t1 as x2 on x2.pk = x1.a;
@@ -4556,15 +4548,13 @@ id select_type table type possible_keys key key_len ref rows Extra
45564548
1 SIMPLE x2 ref PRIMARY PRIMARY 4 test.x0.c 1 Child of 'x0' in pushed join@1
45574549
1 SIMPLE x3 ref PRIMARY PRIMARY 4 test.x2.c 1 Child of 'x2' in pushed join@1
45584550
1 SIMPLE x4 eq_ref PRIMARY PRIMARY 8 test.x0.d,test.x3.b 1 Child of 'x3' in pushed join@1
4559-
update spj_save_counts set val = (select sum(val) from ndbinfo.counters where block_name='DBSPJ' and counter_name='SCAN_ROWS_RETURNED') where counter_name='SCAN_ROWS_RETURNED';
45604551
select straight_join count(*) from t1 as x0
45614552
join t3 as x1 on x0.c=x1.a
45624553
join t1 as x2 on x0.c=x2.a
45634554
join t3 as x3 on x2.c=x3.a
45644555
join t1 as x4 on x0.d=x4.a and x3.b=x4.b;
45654556
count(*)
45664557
4800
4567-
update spj_counts_at_startup set val = val + (select sum(val) from ndbinfo.counters where block_name='DBSPJ' and counter_name='SCAN_ROWS_RETURNED') - (select val from spj_save_counts where counter_name='SCAN_ROWS_RETURNED') where counter_name='SCAN_ROWS_RETURNED';
45684558
drop table t1;
45694559
drop table t2;
45704560
drop table t3;
@@ -5235,32 +5225,24 @@ group by counter_name;
52355225
select spj_counts_at_end.counter_name, spj_counts_at_end.val - spj_counts_at_startup.val
52365226
from spj_counts_at_end, spj_counts_at_startup
52375227
where spj_counts_at_end.counter_name = spj_counts_at_startup.counter_name
5238-
and spj_counts_at_end.counter_name <> 'LOCAL_READS_SENT'
5228+
and spj_counts_at_end.counter_name <> 'READS_NOT_FOUND'
5229+
and spj_counts_at_end.counter_name <> 'LOCAL_READS_SENT'
52395230
and spj_counts_at_end.counter_name <> 'REMOTE_READS_SENT'
52405231
and spj_counts_at_end.counter_name <> 'LOCAL_RANGE_SCANS_SENT'
52415232
and spj_counts_at_end.counter_name <> 'REMOTE_RANGE_SCANS_SENT'
5233+
and spj_counts_at_end.counter_name <> 'SCAN_ROWS_RETURNED'
52425234
and spj_counts_at_end.counter_name <> 'SCAN_BATCHES_RETURNED';
52435235
counter_name spj_counts_at_end.val - spj_counts_at_startup.val
52445236
CONST_PRUNED_RANGE_SCANS_RECEIVED 6
52455237
LOCAL_TABLE_SCANS_SENT 244
52465238
PRUNED_RANGE_SCANS_RECEIVED 25
52475239
RANGE_SCANS_RECEIVED 720
5248-
READS_NOT_FOUND 6616
52495240
READS_RECEIVED 52
5250-
SCAN_ROWS_RETURNED 76386
52515241
TABLE_SCANS_RECEIVED 244
5252-
select sum(spj_counts_at_end.val - spj_counts_at_startup.val) as 'LOCAL+REMOTE READS_SENT'
5253-
from spj_counts_at_end, spj_counts_at_startup
5254-
where spj_counts_at_end.counter_name = spj_counts_at_startup.counter_name
5255-
and (spj_counts_at_end.counter_name = 'LOCAL_READS_SENT'
5256-
or spj_counts_at_end.counter_name = 'REMOTE_READS_SENT');
5257-
LOCAL+REMOTE READS_SENT
5258-
35288
5259-
drop table spj_save_counts;
52605242
drop table spj_counts_at_startup;
52615243
drop table spj_counts_at_end;
5262-
scan_count
5263-
2524
5244+
scan_count_derived
5245+
1.0
52645246
pruned_scan_count
52655247
8
52665248
sorted_scan_count

mysql-test/suite/ndb/t/ndb_join_pushdown.test

Lines changed: 6 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -37,30 +37,6 @@ let $pushed_queries_dropped_at_startup = query_get_value(show status like 'Ndb_p
3737
let $pushed_queries_executed_at_startup = query_get_value(show status like 'Ndb_pushed_queries_executed', Value, 1);
3838
let $pushed_reads_at_startup = query_get_value(show status like 'Ndb_pushed_reads', Value, 1);
3939

40-
# Use this table and the two queries below to turn of meassuring
41-
# SCAN_ROWS_RETURNED for certain bushy scan queries. The reason for this is
42-
# that growth of this counter is platform dependent for these queries. There
43-
# are two reasons for this:
44-
# 1. Distribution hashing (partitioning) of tables is endian dependent. This
45-
# may cause data to be more skewed on some platforms. This again requires more
46-
# batches to scan the table and thus more repeats of repeatable scans (i.e.
47-
# those that will be repeated for each batch of the other branch of a bushy
48-
# scan). This increases the overall scan row count.
49-
# 2. If a timer expires in LQH after receiving SCAN_FRAGREQ, LQH may decide to
50-
# send SCAN_FRAGCONF immediately, even if more tuples could fit in the batch.
51-
# As above this causes more repeats of repeatable scans.
52-
53-
create temporary table spj_save_counts like spj_counts_at_startup;
54-
55-
insert into spj_save_counts values ('SCAN_ROWS_RETURNED', 0);
56-
57-
# Record current counter value.
58-
let $save_scan_rows_returned = update spj_save_counts set val = (select sum(val) from ndbinfo.counters where block_name='DBSPJ' and counter_name='SCAN_ROWS_RETURNED') where counter_name='SCAN_ROWS_RETURNED';
59-
60-
# Update spj_counts_at_startup to compensate for counter increments since
61-
# running save_scan_rows_returned.
62-
let $compensate_scan_rows_returned = update spj_counts_at_startup set val = val + (select sum(val) from ndbinfo.counters where block_name='DBSPJ' and counter_name='SCAN_ROWS_RETURNED') - (select val from spj_save_counts where counter_name='SCAN_ROWS_RETURNED') where counter_name='SCAN_ROWS_RETURNED';
63-
6440
##############
6541
# Test start
6642

@@ -1046,7 +1022,6 @@ connection ddl;
10461022
alter table t1 partition by key(a);
10471023

10481024
connection spj;
1049-
eval $save_scan_rows_returned;
10501025

10511026
explain select count(*) from t1
10521027
join t1 as t2 on t2.a = t1.c
@@ -1077,8 +1052,6 @@ select count(*) from t1 as x1
10771052
join t1 as x2 on x2.a = x1.c and x1.b < 2
10781053
join t1 as x3 on x3.a = x1.c;
10791054

1080-
eval $compensate_scan_rows_returned;
1081-
10821055
connection ddl;
10831056
drop table t1;
10841057
drop table tx;
@@ -2987,7 +2960,6 @@ explain extended select straight_join * from
29872960
# These should be allowed to be executed in 'parallel', depending on
29882961
# only the root operation
29892962
#
2990-
eval $save_scan_rows_returned;
29912963

29922964
explain extended select straight_join count(*) from t1 as x1
29932965
join t1 as x2 on x2.b = x1.a
@@ -3023,8 +2995,6 @@ select straight_join count(*) from t1 as x1
30232995
join t1 as x7 on x7.b = x1.a
30242996
where x3.a < x2.pk and x4.a < x3.pk;
30252997

3026-
eval $compensate_scan_rows_returned;
3027-
30282998
#############
30292999
# If we have an outer join, we can't create an artificial dep. 'through' the outer join.
30303000
# In this case the child scan can't be part of the pushed query.
@@ -3064,8 +3034,6 @@ select straight_join count(*) from t1 as x1
30643034
#
30653035
# Bushy execution is expected for these scans (x2 & x4) wrt. root (x1)
30663036
#
3067-
eval $save_scan_rows_returned;
3068-
30693037
explain extended
30703038
select straight_join count(*) from t1 as x1
30713039
join t1 as x2 on x2.b = x1.a
@@ -3080,8 +3048,6 @@ select straight_join count(*) from t1 as x1
30803048
join t1 as x2 on x2.b = x1.a
30813049
join t1 as x3 on x3.pk = x1.a join t1 as x4 on x4.b = x3.a;
30823050

3083-
eval $compensate_scan_rows_returned;
3084-
30853051
#############
30863052
# Test bushy lookups + 1scan,
30873053
# (Regression test for previous commit: http://lists.mysql.com/commits/117571)
@@ -3195,16 +3161,12 @@ explain select straight_join count(*) from t1 as x0
31953161
join t3 as x3 on x2.c=x3.a
31963162
join t1 as x4 on x0.d=x4.a and x3.b=x4.b;
31973163

3198-
eval $save_scan_rows_returned;
3199-
32003164
select straight_join count(*) from t1 as x0
32013165
join t3 as x1 on x0.c=x1.a
32023166
join t1 as x2 on x0.c=x2.a
32033167
join t3 as x3 on x2.c=x3.a
32043168
join t1 as x4 on x0.d=x4.a and x3.b=x4.b;
32053169

3206-
eval $compensate_scan_rows_returned;
3207-
32083170
connection ddl;
32093171
drop table t1;
32103172
drop table t2;
@@ -3720,21 +3682,15 @@ connection spj;
37203682
select spj_counts_at_end.counter_name, spj_counts_at_end.val - spj_counts_at_startup.val
37213683
from spj_counts_at_end, spj_counts_at_startup
37223684
where spj_counts_at_end.counter_name = spj_counts_at_startup.counter_name
3685+
and spj_counts_at_end.counter_name <> 'READS_NOT_FOUND'
37233686
and spj_counts_at_end.counter_name <> 'LOCAL_READS_SENT'
37243687
and spj_counts_at_end.counter_name <> 'REMOTE_READS_SENT'
37253688
and spj_counts_at_end.counter_name <> 'LOCAL_RANGE_SCANS_SENT'
37263689
and spj_counts_at_end.counter_name <> 'REMOTE_RANGE_SCANS_SENT'
3690+
and spj_counts_at_end.counter_name <> 'SCAN_ROWS_RETURNED'
37273691
and spj_counts_at_end.counter_name <> 'SCAN_BATCHES_RETURNED';
37283692

3729-
# The sum of LOCAL+REMOTE should be constant
3730-
select sum(spj_counts_at_end.val - spj_counts_at_startup.val) as 'LOCAL+REMOTE READS_SENT'
3731-
from spj_counts_at_end, spj_counts_at_startup
3732-
where spj_counts_at_end.counter_name = spj_counts_at_startup.counter_name
3733-
and (spj_counts_at_end.counter_name = 'LOCAL_READS_SENT'
3734-
or spj_counts_at_end.counter_name = 'REMOTE_READS_SENT');
3735-
37363693
connection spj;
3737-
drop table spj_save_counts;
37383694
drop table spj_counts_at_startup;
37393695
drop table spj_counts_at_end;
37403696

@@ -3750,7 +3706,10 @@ let $pushed_reads_at_end = query_get_value(show status like 'Ndb_pushed_reads',
37503706

37513707
# Calculate the change.
37523708
--disable_query_log
3753-
--eval select $scan_count_at_end - $scan_count_at_startup as scan_count
3709+
# There is some random variation in scan_count, probably due to statistics
3710+
# being updated at unpredictable intervals. Therefore, we only test for
3711+
# deviations greater than on tenth of the expected value.
3712+
--eval select round(($scan_count_at_end - $scan_count_at_startup)/2524, 1) as scan_count_derived
37543713
--eval select $pruned_scan_count_at_end - $pruned_scan_count_at_startup as pruned_scan_count
37553714
--eval select $sorted_scan_count_at_end - $sorted_scan_count_at_startup as sorted_scan_count
37563715
--eval select $pushed_queries_defined_at_end - $pushed_queries_defined_at_startup as pushed_queries_defined

0 commit comments

Comments
 (0)