Skip to main content

mysqldump: Incorrect key file for table

Today, mysqldump complained about:

[...]
mysqldump: Couldn't execute 'SELECT /*!40001 SQL_NO_CACHE */ * FROM `COLUMNS`': 
        Incorrect key file for table '/var/run/mysqld/#sql_2935_0.MYI'; 
        try to repair it (126)
mysqldump: Got error: 126: Incorrect key file for table '/var/run/mysqld/#sql_2935_0.MYI'; 
        try to repair it when retrieving data from server
Well, the error message is pretty clear - but there's no table in /var/run/mysqld. In fact, no database should reside in this directory! The server's my.cnf has:
  datadir         = /var/lib/mysql
  tmpdir          = /var/run/mysqld
So, what was going on here? Of course, the internet was there to help :-) Because /var/run was mounted as tmpfs and only 10MB in size, mysqldump appears to have exceeded this space. Resizing /var/run helped:
$ mount -o remount,size=134217728 /var/run                # 128M
Watching /var/run during the next mysqldump run shows how much memory is needed for it to complete:
varrun                128M  2.2M  126M   2% /var/run
varrun                128M  3.8M  125M   3% /var/run
varrun                128M  4.3M  124M   4% /var/run
varrun                128M  5.9M  123M   5% /var/run
varrun                128M  7.6M  121M   6% /var/run
varrun                128M  8.6M  120M   7% /var/run
varrun                128M   11M  118M   8% /var/run
varrun                128M   12M  117M   9% /var/run
varrun                128M   13M  116M  10% /var/run
varrun                128M  1.3M  127M   2% /var/run
All databases combined are only ~750MB in size, but resizing /var/run a bit might have been long overdue anyway :-)