2008
03.07

I learned something new about myisamchk. When doing a recovery of the data file, it creates not one but two temporary files. I knew about the TMD it creates in $datadir when rebuilding the MYD file but it creates a second temporary file using an old and rather annoying technique (which involves creating a file using the standard C ‘open()’ call, then deleting the file without closing the file descriptor.) I discovered this when myisamchk told me “Disk is full writing ‘/tmp/STQ3p9UF’ (Errcode: 28).” I looked in /tmp and didn’t see that file. So I did a

# lsof | grep delete

and low-and-behold, there it was. You know, as a sys admin, that really annoys me. I don’t care that it creates temporary files to do its thing. In fact, I expect it, but I at least want to know about it so I can plan accordingly. My /tmp partition only had 2.5 gigs of space and the table’s MYD was over 4 gigs in size. If I had known about this extra temp file, I would have used –tmpdir=/some/place/else before I started and not had myisamchk crap out on me in the first place.

  1. Same thing happened to me. A table crashed during the nightly check/optimize table run and a full /tmp filesystem was the reason. On Solaris /tmp is memory based, so using /var/tmp/ as tmpdir can freeup some memory , this is also true for some Linux systems which have /dev/shm mounted on /tmp.

    Running lsof w/o arguments is a bad idea, you should try “lsof +L1″.

    Please note that tmpdir can be set in the mysqld config section for CHECK TABLE and in the client section for myisamchk.