Bug #68140 Error:13 MyISAM table file not found
Submitted: 22 Jan 2013 8:49 Modified: 17 Sep 2013 23:40
Reporter: dragos coco Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: MyISAM storage engine Severity:S3 (Non-critical)
Version:5.5.28 OS:Windows (Server 2008 x64)
Assigned to: CPU Architecture:Any
Tags: exception, file-not-found, table

[22 Jan 2013 8:49] dragos coco
Description:
I have a set of files (around 20MB each) that needs to be inserted into a table in mysql. The insert is done in a loop for all files (single threaded). This works usually fine, but from time to time I am getting the following exception: "File '.table.MYD' not found (Errcode: 13)" for one file in the middle of the set (the first 50 ran ok, next 2-3 will fail and then the following will run fine again). If I just re-run the queries for the failed files in mysql workbench (or re-run the failed ones), they are working fine. The table is just created, with no indexes - so problems like 'index failed', table fragmentation or any other problems should not be there.

Below is the complete stacktrace:
File '.dbtable.MYD' not found (Errcode: 13)
----------------------------------
 at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
 at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int32& insertedId)
 at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
 at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
 at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
 at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
 at Utils.SqlUtils.ExecMysql(String sql, String connection)
 at Utils.MySqlExecQueue.DoExec(Object data)
----------------------------------
MySql.Data

where:
1. ExecMysql - looks like

using (MySqlConnection cnn = new MySqlConnection(connection))
{
  cnn.Open();

  using (MySqlCommand cmd = new MySqlCommand(sql, cnn))
  {
    cmd.CommandType = CommandType.Text;
    cmd.ExecuteNonQuery();
  }
}

2. DoExec is a method that pics the files from a queue, creates the sql statement and calls ExecMysql above.
3. the inserting code and mysql are on the same machine (Windows 2008, x64);
4. there are no _antiviruses_ or any other tool running on that machine that may lock the table file (as found on some blogs). On that machine I have installed IIS, MSSQL
5. the c# (.net 4 x64) code is using mysql connector 6.5.4, the mysql version is 5.5.28;

I have implemented a dummy workaround like 'try-to-insert-while-13error-exception-is-thrown' but I have a strong feeling that this is not the correct solution: I have received it also when running a SELECT after the data and the indexing were complete.

In case it matters, from time to time I also got the exception: Error on rename of '.\db\table.MYD' to '.\db\#sql2-4e4-1677.MYD' (Errcode: 17) ... 

Any ideea what is going on and how to fix this issue once and for all?

How to repeat:
Hard to repeat. There are days when I get this exception few times, there are days when everything works fine.

Suggested fix:
The only fix I could think of is to build a loop to retry - but this only guarantees the number of iterations and not the success of mysql statement.
[22 Jan 2013 18:46] Matthew Lord
We're sorry, but the bug system is not the appropriate forum for asking help on using MySQL products. Your problem is not the result of a bug.

Support on using our products is available both free in our forums at http://forums.mysql.com/ and for a reasonable fee direct from our skilled support engineers at http://www.mysql.com/support/

Thank you for your interest in MySQL.
[23 Jan 2013 16:14] dragos coco
It's not really a help request (oh well, kind of ... ) ... I think it's a bug because I was able to reproduce it on other _clean_ machines with a slightly different architecture. Bottom line is I am getting the above-described exceptions when I constantly load data - it's true this is not constant, but it is there.
[17 Sep 2013 23:40] dragos coco
This thing is still happening. Could this be an issue related with bulk loading? This is the place where it happens most of the time.