Bug #53752 Simplifier unable to produce test file upon simplifying a crash
Submitted: 18 May 2010 13:47 Modified: 18 May 2010 13:50
Reporter: John Embretsen Email Updates:
Status: Verified Impact on me:
Category:Tools: Random Query Generator Severity:S2 (Serious)
Version:bzr OS:Any
Assigned to: Bernt Marius Johnsen CPU Architecture:Any

[18 May 2010 13:47] John Embretsen
With RQG bzr branch lp:randgen simplification of a crashing query can be done by running a utility script against the populated datadir, using various RQG modules. In this report the utility script mentioned is util/simplify-crash.pl.

It is not entirely clear at this point whether the bug is in the utility script or in the RQG itself.

Upon running the script after a crash occurrence, the script runs for a while and is able to simplify the query as expected. However, instead of also producing a simplified test case (in a .test file), the simplifier seems to fail with an error message:

mysqldump: Got error: 2003: Can't connect to MySQL server on 'localhost' (111) when trying to connect
DBI connect('host=','',...) failed: Can't connect to MySQL server on '' (111) at lib/GenTest/Simplifier/Tables.pm line 69
Can't call method "do" on an undefined value at lib/GenTest/Simplifier/Tables.pm line 71.

How to repeat:
This was observed using lp:randgen of revid pstoev@mysql.com-20100517064103-bg9ixrdvh4ur0umy and mysql-6.0-codebase-bugfixing of revid alik@sun.com-20100511120528-bxlgodfgv6s301d1, using a valgrind-enabled build on Linux 64-bit.

RQG command line:

perl runall.pl \
--queries=100K \
--basedir=$CODE \
--grammar=conf/optimizer/outer_join.yy \
--gendata=conf/optimizer/outer_join.zz \
--Validator=MarkErrorLog \
[18 May 2010 13:53] John Embretsen
Full output of simplify_crash.pl run.

Attachment: simplify-crash.log (text/plain), 415.35 KiB.

[18 May 2010 13:55] John Embretsen
Simplification utility script (slightly modified (query etc.) from simplify-crash.pl)

Attachment: simplify-crash-valgrind.pl (application/octet-stream, text), 3.87 KiB.

[18 May 2010 15:53] Philip Stoev
The reason for this behavior is that when the test case is produced, EXPLAIN SELECT is issued in order to record the query plan within the test case. Unfortunately, for this particular SELECT crash, EXPLAIN SELECT crashes as well, causing simplified test generation to fail.

Quick workaround:

In lib/GenTest/Simplifier/Test.pm , disable the block around EXPLAIN.

Possible longer-term solution:
Handle crashing queries separately by passing a special flag to Simplifier::Test, which would cause the EXPLAIN call to be skipped altogether. EXPLAIN output is not strictly required for fixing crashing queries, so can safely be ommitted when generating a simplified test case.
[18 May 2010 16:35] Philip Stoev
Quick and dirty patch:

=== modified file 'lib/GenTest/Simplifier/Test.pm'
--- lib/GenTest/Simplifier/Test.pm      2010-03-30 11:54:09 +0000
+++ lib/GenTest/Simplifier/Test.pm      2010-05-18 15:48:58 +0000
@@ -169,12 +169,12 @@
                        foreach my $ex (0..1) {
                                if (defined $executors->[$ex]) {
                                        $test .= "/* Query plan Server $ex:\n";
-                                       my $plan =  $executors->[$ex]->dbh()->selectall_arrayref("EXPLAIN $query");
+#                                      my $plan =  $executors->[$ex]->dbh()->selectall_arrayref("EXPLAIN $query");

-                                       foreach my $row (@$plan) {
-                                               $test .= "# |".join("|",@$row)."|\n";
-                                       }
-                                       $test .= "# */\n\n";
+#                                      foreach my $row (@$plan) {
+#                                              $test .= "# |".join("|",@$row)."|\n";
+#                                      }
+#                                      $test .= "# */\n\n";