Closed ghost closed 8 years ago
could you try to create connection with debug: true
flag?
I did. Got this piece of info before exit:
Add command: query Sending query command: USE ssDataProxy 1 1125 <== query#start(0,,20)
is that connection from pool? Looks like server closed connection but for some reason you are not getting callback with error
Yeah, connection from pool. Well anyway callback get lost somewhere on the way. How ti figure out where?
try to debug if connection.on('error') handler present and what happens in that handler Looks like pool manager is marking connection as closed and removes from list of active connections but does not call callback
console.log( connection.listeners('error') )
console.log( connection.listeners('error')[0].toString() )
Alright.
connection.listeners is undefined. Can find only two string in file connection.js:
stream.removeAllListeners('data'); mysql2/lib/connection.js:185 this.stream.removeAllListeners('data'); mysql2/lib/connection.js:265
Tracked problem further. Now in file mysql2/lib/commands/query.js
Query.prototype.start = function(packet, connection) { if (connection.config.debug) { console.log(' Sending query command: %s', this.query); } this._connection = connection; var cmdPacket = new Packets.Query(this.query); connection.writePacket(cmdPacket.toPacket(1)); console.log("Before Query.prototype.resultsetHeader"); return Query.prototype.resultsetHeader; };
I can see log "Before Query.prototype.resultsetHeader" but can't see log which follows as first command in that method.
if connection is closed before data is sent from server Query.prototype.resultsetHeader is not called, this is expected. Could you put log here: https://github.com/sidorares/node-mysql2/blob/master/lib/connection.js#L101 and see if error is emitted (and if there is connection close et all)?
Added there log but don't see it. Seems app fails even before that. Also added log on stream.on('data') and on that bad round don't see this log either.
so the process just exits without calling callback? Are you sure there is no process.exit()
somewhere?
Myself only set console.log or console.dir in mysql2. And in my code absolutely sure there is no process.exit(); Also few times already (today) app managed to proceed that troubled round and continue executing next rounds.
one more guess: could it be that proccess is killed with OOM killer? can you try to reproduce the problem running under strcace?
I work under Windows 8 and actually it does not eat all resources. Later rounds much more massive and working just fine. And what means running under strcace?
Got it!
on stream error log { [Error: read ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }
added log mysql2/lib/connection.js:72
this.stream.on('error', function(err) { console.log("on stream error log"); console.log(err); connection.emit('error', err); });
looks like current command callback is never called indeed if there is stream error
What can be done about that?
Try "stream-error-callback" branch or just apply what I did in b7e296579dbd3549671c59b981c6eb9ef8f0d935 to your code. Previously only unexpected end was propagated as error to all commands as callback with error parameter, now also stream error
Thank you very much!
I'll need to add tests before releasing this, but thank you for pointing in right direction!
Alright. Glad to help mysql2 project.
Another kind of error got on that place:
{ [Error: This socket has been ended by the other party] code: 'EPIPE' }
Hi, I'm working on app which download and process database. After downloading when I try to insert data in mysql on certain rounds program failing silently. I tracked problem to connection.query method from mysql2 library,even though query executed its callback never executed and program just exits.
Sometimes this problem not bother but other time can execute up to 20 times my app and it exits on very same round giving no error at all.
I'm working on Windows 8, node 0.12.7, mysql2 0.15.8.
I can't see any special about circumstances, it fails on query "USE my dbName" (have to do that several times cause otherwise get mysql error that database not chosen. Using pool = mysql.createPool() from mysql2).
Here is code:
`function addAndUpdateUsers(table,usersData,cb){
I can see log "before use", but don't see "after use".
Ready to give any additional info needed.