0

I am trying to insert a file of 50mb to mysql using node.js. I call stored procedure that takes the full content and inserts it (the whole 50MB at once). Version of mysql 2.13. For small file this code mostly works (some details are skipped in case something seems inconsistent). The error is observed only with a big file.

var mysql=require('mysql');
function InsertTrace(guid, device, testName,  testEvent, traceData) {

pool.query('call insert_trace(?,?,?,?,?)', [guid, device, testName, testEvent, traceData], function (err, results, fields) {
    if (err)
    {
        console.error("[DB]: Failed to insert trace data for " + guid + ", " + device + ", test " + testName + "/" + testEvent + " total bytes: " + traceData.length);
        console.error("[DB]: insert error:", err)
        return;
    }
});
}
var data = fs.readFileSync('big.json', 'utf8');
IraceTrace('99', 'ddd', 'test1', 'event15', data);

The error is:

{ Error: read ECONNRESET
    at exports._errnoException (util.js:1022:11)
    at TCP.onread (net.js:569:26)
    --------------------
    at Pool.query (mysql\lib\Pool.js:199:23)
     ...
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)
  code: 'ECONNRESET',
  errno: 'ECONNRESET',
  syscall: 'read',
  fatal: true }

If the mysql max size was the problem I expect to see the mysql error, not connection reset so I can't figure out what the problem is.

1
  • ... Maybe the code you use with the driver ? Commented Mar 17, 2017 at 14:15

1 Answer 1

1

Had to change max_allowed_packet to be more than the size of the blob

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.