0
votes

I'm using this method to insert a large blob into my mySQL database (Blob size ~40MB) After ~15 seconds it throws a exception. The whole thing here works with blobs smaller then ~20MB.

protected override int internalExecuteInt(string SQL, byte[] Blob)
{
    using (MySqlCommand cmd = new MySqlCommand(SQL, connection))
    {
        if (Blob != null)
        {
            cmd.CommandTimeout = 600;
            cmd.Parameters.AddWithValue("@blob", Blob);
        }
        return cmd.ExecuteNonQuery();
    }
}

...
internalExecuteInt("INSERT INTO images (image) VALUES (@blob)", myLargeBlob);
...

Exception:

MySqlException: Fatal error encountered during command execution.

Inner exception:

SocketException: An existing connection was forcibly closed by the remote host

I have already changed net_read_timeout (600), net_write_timeout (600), wait_timeout (28800), slave_net_timeout (3600) and interactive_timeout (28800).

The "image" column is a LONGBLOB

3
What type is "image" BLOB? It's probably too big for that datatype. - Rob
@Rob It's a LONGBLOB now, but it still doesn't work - teamalpha5441

3 Answers

0
votes

Try changing the column to a LONGBLOB

0
votes

I had a similar issue once and increasing log file helped. See "innodb_log_file_size" variable in my.ini - it usually needs to be twice as big as your blob. Although still at some point (like 200MB+) it may still not help...

0
votes

I had faced same issue.
Setting following variable helped me.

set global bulk_insert_buffer_size=99999744;