Bug #1372 When mysqld starts it dels the temp tables of other mysqld having same tmpdir
Submitted: 22 Sep 2003 6:09 Modified: 22 Sep 2003 6:18
Reporter: Guilhem Bichot Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.0 OS:Any (all)
Assigned to: Guilhem Bichot CPU Architecture:Any

[22 Sep 2003 6:09] Guilhem Bichot
Description:
When mysqld starts, it does the equivalent of 'rm -f tmpdir/#sql*'
(where tmpdir is the name of mysqld's tmp dir, which can be read with
SHOW VARIABLES LIKE 'tmpdir').
So if another mysqld has the same tmpdir, this will delete all #sql*
files belonging to this other server, which is wrong (for example it will deletes temporary tables in use).
Note that this looks like BUG#1357 but is not the same.

How to repeat:
Start 2 mysqld with the same tmpdir.
On first do CREATE TEMPORARY TABLE t(a int);
this produces these files:
[guilhem@gbichot2 guilhem]$ ls /tmp/#*
/tmp/#sql9d7_4_0.frm  /tmp/#sql9d7_4_0.MYD  /tmp/#sql9d7_4_0.MYI
shutdown the 2nd mysqld and restart it.
[guilhem@gbichot2 guilhem]$ ls /tmp/#*
ls: /tmp/#*: No such file or directory
[22 Sep 2003 6:18] Guilhem Bichot
On Unix: deleting a file for which there is an open handle does not truly delete it (does not release the file space) until the open handle is closed. So the 2nd server still has it even if we don't see it with 'ls'.
On Windows: deleting a file for which there is an open handle is impossible, so the 2nd server will still have his file.