#At file:///home/bm136801/my/ordpar-51/ based on revid:bjorn.munch@stripped
2948 Bjorn Munch 2010-11-02
Bug #57840 MTR: parallel execution breaks with smart ordering of test cases
There were actually more problems in this area:
Slaves (if any) were unconditionally restarted, this appears unnecessary.
Sort criteria were suboptimal, included the test name.
Added logic to "reserve" a sequence of tests with same config for one thread
modified:
mysql-test/lib/mtr_cases.pm
mysql-test/mysql-test-run.pl
=== modified file 'mysql-test/lib/mtr_cases.pm'
--- a/mysql-test/lib/mtr_cases.pm 2010-08-30 09:25:10 +0000
+++ b/mysql-test/lib/mtr_cases.pm 2010-11-02 14:52:07 +0000
@@ -183,24 +183,30 @@ sub collect_test_cases ($$$) {
# Append the criteria for sorting, in order of importance.
#
push(@criteria, "ndb=" . ($tinfo->{'ndb_test'} ? "A" : "B"));
+ push(@criteria, $tinfo->{template_path});
# Group test with equal options together.
# Ending with "~" makes empty sort later than filled
my $opts= $tinfo->{'master_opt'} ? $tinfo->{'master_opt'} : [];
push(@criteria, join("!", sort @{$opts}) . "~");
+ # Add slave opts if any
+ if ($tinfo->{'slave_opt'})
+ {
+ push(@criteria, join("!", sort @{$tinfo->{'slave_opt'}}));
+ }
$sort_criteria{$tinfo->{name}} = join(" ", @criteria);
}
@$cases = sort {
- $sort_criteria{$a->{'name'}} . $a->{'name'} cmp
- $sort_criteria{$b->{'name'}} . $b->{'name'}; } @$cases;
+ $sort_criteria{$a->{'name'}} cmp $sort_criteria{$b->{'name'}}; } @$cases;
# For debugging the sort-order
# foreach my $tinfo (@$cases)
# {
- # print("$sort_criteria{$tinfo->{'name'}} -> \t$tinfo->{'name'}\n");
+ # my $tname= $tinfo->{'name'};
+ # my $crit= $sort_criteria{$tinfo->{'name'}};
+ # print("$crit\n\t$tname\n");
# }
-
}
if (defined $print_testcases){
=== modified file 'mysql-test/mysql-test-run.pl'
--- a/mysql-test/mysql-test-run.pl 2010-10-19 12:01:14 +0000
+++ b/mysql-test/mysql-test-run.pl 2010-11-02 14:52:07 +0000
@@ -662,22 +662,45 @@ sub run_test_server ($$$) {
next;
}
- # Prefer same configuration, or just use next if --noreorder
- if (!$opt_reorder or (defined $result and
- $result->{template_path} eq $t->{template_path}))
- {
- #mtr_report("Test uses same config => good match");
- # Test uses same config => good match
- $next= splice(@$tests, $i, 1);
- last;
- }
-
# Second best choice is the first that does not fulfill
# any of the above conditions
if (!defined $second_best){
#mtr_report("Setting second_best to $i");
$second_best= $i;
}
+
+ # Smart allocation of next test within this thread.
+
+ if ($opt_reorder and $opt_parallel > 1 and defined $result)
+ {
+ my $wid= $result->{worker};
+ # Reserved for other thread, try next
+ next if (defined $t->{reserved} and $t->{reserved} != $wid);
+ if (! defined $t->{reserved})
+ {
+ # Reserve similar tests for this worker, but not too many
+ my $maxres= (@$tests - $i) / $opt_parallel + 1;
+ for (my $j= $i+1; $j <= $i + $maxres; $j++)
+ {
+ my $tt= $tests->[$j];
+ last unless defined $tt;
+ last if $tt->{template_path} ne $t->{template_path};
+ my $opt1= join("", sort @{$t->{master_opt}});
+ my $opt2= join("", sort @{$tt->{master_opt}});
+ last if $opt1 ne $opt2;
+ $opt1= join("", sort @{$t->{slave_opt}});
+ $opt2= join("", sort @{$tt->{slave_opt}});
+ last if $opt1 ne $opt2;
+ my $tname= $tt->{name};
+ # mtr_report("Reserve $tname for $wid");
+ $tt->{reserved}= $wid;
+ }
+ }
+ }
+
+ # At this point we have found next suitable test
+ $next= splice(@$tests, $i, 1);
+ last;
}
# Use second best choice if no other test has been found
@@ -4575,17 +4598,6 @@ sub server_need_restart {
}
}
- # Temporary re-enable the "always restart slave" hack
- # this should be removed asap, but will require that each rpl
- # testcase cleanup better after itself - ie. stop and reset
- # replication
- # Use the "#!use-slave-opt" marker to detect that this is a "slave"
- # server
- if ( $server->option("#!use-slave-opt") ){
- mtr_verbose_restart($server, "Always restart slave(s)");
- return 1;
- }
-
my $is_mysqld= grep ($server eq $_, mysqlds());
if ($is_mysqld)
{
Attachment: [text/bzr-bundle] bzr/bjorn.munch@oracle.com-20101102145207-i2szuksit8f10n63.bundle
| Thread |
|---|
| • bzr commit into mysql-5.1-mtr branch (bjorn.munch:2948) Bug#57840 | Bjorn Munch | 2 Nov |