Bug #2579 myisamchk -u not cleaning up .TMD file when removal of .MYD file fails.
Submitted: 30 Jan 2004 6:49 Modified: 31 Jan 2004 10:26
Reporter: Matthew Lord Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:4.0.17 OS:
Assigned to: CPU Architecture:Any

[30 Jan 2004 6:49] Matthew Lord
Description:
If you run myisamchk -u on windows without first issuing unlock tables, myisamchk is unable to remove the original table's .MYD file.  It aborts with that error but it does not remove the .TMD file that it created and that leftover file seems to cause subsequent mysiamch -u calls to fail as well.  

How to repeat:
try and pack any table with myisampack.  Then get a file descriptor to that table by doing a select on it.  Then try and unpack the table with myisampack -u w/o issuing a flush tables.  Then continue to try myisampack -u.  Delete the .TMD file that it created the first time and you should be able to get it to work.

Suggested fix:
have myisamchk remove the .TMD file upon an errors.
[31 Jan 2004 7:15] MySQL Verification Team
Simultaneous running of myisamchk and MySQL server is not supported.
[31 Jan 2004 10:26] Sergei Golubchik
myisamchk usually does not remove TMD files automatically - not only in the described situation (windows, mysqld keeping a compressed table opened, myisamchk -u) but generally. It is intentional, you have to either remove them manually, or use -f switch:

% myisamchk --help
...
  -f, --force         Overwrite old temporary files.
...