sidorares / node-mysql2

:zap: fast mysqljs/mysql compatible mysql driver for node.js
https://sidorares.github.io/node-mysql2/
MIT License
4.05k stars 613 forks source link

Receiving "Connection lost: The server closed the connection." with createPool #2247

Open jasonterando opened 11 months ago

jasonterando commented 11 months ago

When calling execute or query from a Pool returned from createPool, I'm occasionally getting the error "Connection lost: The server closed the connection.". This error looks like it is coming from a stream close event in connection.js.

My understanding is that Pool should automatically capture this condition and recreate a connection, but that does not appear to be happening (i.e. I don't understand why I would be seeing this error when using Pool.execute or Pool.query. I'm not seeing anything in Pool.getConnection/query/execute that appear to be set up to handle a closed connection. Do I need to write my own error handling around this?

As context, I'm using this from Lambda to connect to RDSProxy, so that makes it even more fun to diagnose :)

Thanks

ortonomy commented 11 months ago

We're also seeing similar issues between our lambdas and proxy. Except the library is saying Can't add new command when connection is in closed state...

We never explicitly close any connections in our lambdas...

robert-pitt-foodhub commented 1 month ago

Check #3020 for possible reason