From: Bjorn Munch Date: November 2 2010 2:55pm Subject: bzr commit into mysql-5.1-mtr branch (bjorn.munch:2948) Bug#57840 List-Archive: http://lists.mysql.com/commits/122553 X-Bug: 57840 Message-Id: <201011021455.oA2EtDrA002723@khepri15.norway.sun.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0101034799==" --===============0101034799== MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline #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) { --===============0101034799== MIME-Version: 1.0 Content-Type: text/bzr-bundle; charset="us-ascii"; name="bzr/bjorn.munch@stripped" Content-Transfer-Encoding: 7bit Content-Disposition: inline # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: bjorn.munch@stripped # target_branch: file:///home/bm136801/my/ordpar-51/ # testament_sha1: b12fb74bfaacb4686a030c81d376b6b84b6cfd3c # timestamp: 2010-11-02 15:55:13 +0100 # base_revision_id: bjorn.munch@stripped\ # fltvohh2z890zgsd # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWfTbx40AA4PfgFAwfO///3IC HA6////6YAfZ2t13X2XpAe963netTyroDqNjCSJCPSJqflTxT9U2m1TeVPaI9KejRG1HqNpNNABK IE0GTImqeo/UxDUZNAABoBoMg01GIlHk0mE0yPUNpADQAANAaBIiCkyZGU8JMRk2k2kyMR6gGgaA HNMTJk0YTBMTTAJgEMEYEYBJEQBT0wpjTTU0ZNMo9SfqaJ4oaAAyKAgUIiKAh2kQaSD8XP6K6Vg4 cwi7nHhsyZhNykPfwmmXK8Tl3dY1rmrVDaGn9XwA954onffFQM1a4Ssa6gSULUJttttt8ahQMlM0 6JNGfZrevUU1vBxH4jbM5H8M6lcneYhglh+ZB5E7aNEvLzkr6jkbhhmJteF0c+yuLozTXshcrh8D 5ng58Q4peuC089G1S1J0aMFt1Bvh70BuE4bHxzqyDINTFJ5wszyWs0nM7fG6woS6r4LgcwPd0Rzc RwMikI5QypjmrmHmvKyhe5O9+XSbmgvrSazCqNAE5VuXkarWdoKYU5lCmscHXVGwUPgt2fnTb0ym nVkFVVQWMaAwzOL1sjuXfBnfc3ecHiyXkwqtNm4zAy7TdxkUcBwxFohJingGyciJHULRwu2yvft2 QKGWep4Wzk+2Nmp9lsIoxkZAtQpp+k7f0xeIZj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