Description
The issue is the same #566 It has been marked as closed but the problem is still here I am using node 0.12.18 with mysqljs 2.15.0
We have the database with 1.5kk rows in someTable and the following code with long async result handler:
var db = mysql.createConnection(dbConf);
var q = db.query("SELECT * FROM someTable");
var count = 0;
q.on("end", done);
q.on("error", function (err) {console.error(err.stack || err);});
q.on("result", function (row) {
console.log("row:", ++count, row.id);
db.pause()
setTimeout(function () {
db.resume();
}, 1000);
});
The script fails in about 15 minutes with error PROTOCOL_CONNECTION_LOST on processing ~900 row.
The cause of this error can be revealed by tcpdump. Try to monitor all traffic between your script and the database server in real-time. The server will finish to transfer data in about 5 minutes. The db.pause()/db.resume() calls do not affect it. The server's response will be buffered by driver and will wait for processing by "long async result handler". Meanwhile the server itself will be idle and after inactivity timeout (10 minutes) will close the connection.