Debugging MySQL with Valgrind

The mysql-test-run script (a.k.a. mtr) has build-in options for running testing MySQL with Valgrind.

Building for Valgrind

If you’re not sure how to build for Valgrind, a build script (in the BUILD directory) that includes one of the following in its name might be for you:

  • debug
  • debug-max
  • valgrind
  • valgrind-max

Try one of these, for example:

$ ./BUILD/compile-pentium64-debug-max
$ ./BUILD/compile-pentium64-valgrind-max

Running Testcases with Valgrind

To see the Valgrind options for running the MySQL test cases, issue these commands (starting in the base directory of the MySQL source code, build with debugging enabled):

$ cd mysql-test
$ ./mysql-test-run --help | less

Note the options that include “valgrind”

To run mysqld tests with valgrind, type something like:

$ ./mysql-test-run --valgrind-mysqld

If you want the tests to continue after warnings or errors, add the —force option:

$ ./mysql-test-run --valgrind-mysqld --force

(If you don’t like typing “mysql-test-run”, use its symlink: “mtr”)

$ ./mtr --valgrind-mysqld --force

To increase the maximum number of test failures before quitting, use the —max-test-fail=N option (N value of 0 means no limit).:

$ ./mtr --valgrind-mysqld --force --max-test-fail=0

 

If you get the message “Test suite timeout! Terminating …”, you might increase the —suite-timeout default to more than the default 300 minutes:

$ ./mtr --valgrind-mysqld --force --max-test-fail=0 --suite-timeout=500


My Favorite

$ ./mtr --valgrind-mysqld --force --max-test-fail=0 | tee ~/valgrind.out/this_version.out