Temporary file behavior… (and how lsof save my life)
I would like to share this story based on a true event about the temporary files behavior in MySQL.
MONyog reports this error to my already full mailbox several times a day :
1 – Catch the query (if you can) !
I don’t have access to the client logs but I would like to know which query is involved in this error.
Let me explain how I can retrieve informations about this query with MONyog and a very simple shell loop :
- Enable the query sniffer in MONyog (based on processlist) : Edit server -> Advanced settings -> Sniffer settings
- Monitor your MySQL TMPDIR directory with this simple shell loop :
- [ Use this command to retrieve the MySQL temporary directory : show variables like 'tmpdir'; ]
- [ In this case : tmpdir=/database/tmp ]
while [ 1 = 1 ]; do { date;ls -artlh /database/tmp ; df -h /database/tmp;
lsof | grep mysql | grep /database/tmp;sleep 1; }; done
With this loop, I can follow in real time the informations about the files created in the MySQL temporary directory and it will be very useful to find how exactly the error happens (see below).
ERROR 3 (HY000): Error writing file '/database/tmp/MYakhJC5' (Errcode: 28) Error (Code 3): Error writing file '/database/tmp/MYakhJC5' (Errcode: 28) Error (Code 1028): Sort aborted
# perror 28 OS error code 28: No space left on device
2 – No space left on device, really ?!
total 2,3G drwxrwx--- 11 mysql mysql 4,0K 16 févr. 10:37 .. -rw-rw---- 1 mysql mysql 6 6 avril 15:39 mysql.pid srwxrwxrwx 1 mysql mysql 0 6 avril 15:39 mysql.sock -rw-rw---- 1 mysql mysql 1,0K 12 avril 15:41 #sql_7237_0.MYI -rw-rw---- 1 mysql mysql 2,3G 12 avril 15:42 #sql_7237_0.MYD -rw-rw---- 1 mysql mysql 1,0K 12 avril 15:42 #sql_7237_5.MYI -rw-rw---- 1 mysql mysql 0 12 avril 15:42 #sql_7237_5.MYD drwxrwx--- 2 mysql mysql 4,0K 12 avril 15:43 .
3 - ”Was passiert ?!”
4 – What next ?
The killer question : why did you have only 6.5 GB for your temporary space ?
Answer : Why not
You have to consider this behavior to set your temporary space properly, specially if this space is a ramdisk filesystem.
Tschüs !
PS : I let the experts explains why these two additional files are created (hint : look at the Exta column)
PlanetMySQL Voting:
Vote UP /
Vote DOWN
Read more at: http://planet.mysql.com/






