Bug #56125 MTR2 start-and-exit removes server tmpdir, server becomes not operational
Submitted: 19 Aug 2010 17:58 Modified: 13 Nov 2010 16:42
Reporter: Elena Stepanova Email Updates:
Status: Closed Impact on me:
None 
Category:Tools: MTR / mysql-test-run Severity:S3 (Non-critical)
Version:5.1, 5.5, 5.6 OS:Any
Assigned to: Bjørn Munch CPU Architecture:Any

[19 Aug 2010 17:58] Elena Stepanova
Description:
If MTR2 with --start-and-exit option detects on server startup that tmp/socket path is too long, it creates an alternative one. However, it removes the newly created folder before exiting.

Since it affects not only socket but the entire tmp folder, the started server becomes non-functional as any operation which requires tmp folder fails with 'No such file or directory'.

MTR1 works differently in two ways. First, it only creates a shorter path for socket, but leaves tmp folder intact. Second, it does not remove anything while exiting.

How to repeat:
- run mysql-test-run.pl --start-and-exit --vardir=<long enough path>
- wait till MTR starts the server and exits
- see that server tmpdir does not exist.

Suggested fix:
MTR has the following END block:

END {
  if ( defined $opt_tmpdir_pid and $opt_tmpdir_pid == $$ )
  {
    # Remove the tempdir this process has created
    mtr_verbose("Removing tmpdir '$opt_tmpdir");
    rmtree($opt_tmpdir);
  }
}

Either make the logic smarter, e.g. not define opt_tmpdir_pid if MTR runs in start-and-exit mode, or remove the block altogether.
[28 Sep 2010 11:37] Bjørn Munch
It's easy enough to not delete the directory when running with --start-and-exit but then who's going to delete it? This creates another problem: a pile-up of used tmp directories. You can't get mysqld to delete them. Admittedly, this is a smaller problem than the server failing...
[28 Sep 2010 12:15] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/119271

2934 Bjorn Munch	2010-09-28
      Bug #56125 MTR2 start-and-exit removes server tmpdir, server becomes not operational
      This happens when creating new tmpdir due to too long socket path
      Don't delete it if --start-and-exit, but warn user to do it.
[28 Sep 2010 13:59] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/119283

2935 Bjorn Munch	2010-09-28
      Bug #56125 MTR2 start-and-exit removes server tmpdir, server becomes not operational
      This happens when creating new tmpdir due to too long socket path
      Don't delete it if --start-and-exit, but warn user to do it.
[28 Sep 2010 15:00] Bjørn Munch
Pushed to -mtr branches
[7 Oct 2010 22:57] Paul DuBois
Changes to test suite. No changelog entry needed.
[1 Nov 2010 19:02] Bugs System
Pushed into mysql-5.1 5.1.53 (revid:build@mysql.com-20101101184443-o2olipi8vkaxzsqk) (version source revid:build@mysql.com-20101101184443-o2olipi8vkaxzsqk) (merge vers: 5.1.53) (pib:21)
[9 Nov 2010 19:43] Bugs System
Pushed into mysql-5.5 5.5.7-rc (revid:sunanda.menon@sun.com-20101109182959-otkxq8vo2dcd13la) (version source revid:sunanda.menon@sun.com-20101109182959-otkxq8vo2dcd13la) (merge vers: 5.5.7-rc) (pib:21)
[13 Nov 2010 16:05] Bugs System
Pushed into mysql-trunk 5.6.99-m5 (revid:alexander.nozdrin@oracle.com-20101113155825-czmva9kg4n31anmu) (version source revid:alexander.nozdrin@oracle.com-20101113152450-2zzcm50e7i4j35v7) (merge vers: 5.6.1-m4) (pib:21)
[13 Nov 2010 16:30] Bugs System
Pushed into mysql-next-mr (revid:alexander.nozdrin@oracle.com-20101113160336-atmtmfb3mzm4pz4i) (version source revid:vasil.dimov@oracle.com-20100629074804-359l9m9gniauxr94) (pib:21)