Closed invaderb closed 5 months ago
Is it using Docker Swarm?
no I'm just running the node processes with pm2 on a linux VM and the mariadb service is also just on a linux VM
no I'm just running the node processes with pm2 on a linux VM and the mariadb service is also just on a linux VM
But they connect Via VPN, correct?
Could you reduce the maxIdle to zero? I seen a lot of problem on open connection using mysql2 lib with opened connection especially if the config between Maria DB and mysql2 config does not match. Especially for idle timeout.
ok let me try that and report back
ok after a few days of that change being deployed the ETIMEDOUT errors have stopped, what is the config mismatch thats causing this?
ok after a few days of that change being deployed the ETIMEDOUT errors have stopped, what is the config mismatch thats causing this?
The idle time out on the mysql/mariadb, and the other problem is the network (your VPN).
I seen many problem with MySQL2 driver with kubernetes, docker swarm, and other that's virtual network. I have one myself last time and after rechecking because of IPVS on kubernetes.
MySQL2 keep alive keep getting feedback even mysql/mariadb server closed, causing when reusing the connection pool you got bad connection, and ends up with timeout connection, which is sucks.
The first way to tackle that is reducing the idle opened connection to zero, and 2nd thing is to reduce the max Idle time to below 5 minutes if you connection reliable never have interuption (IPVS only open connection for 15 minutes then forget about it), or don't allow any idle connection at all
Anyway if your problem is solved with that, then please do close the issue ticket, because it's not mysql2 driver fault at the first place.
@benyaminl Thank you for the explanation and help on this really appreciate it.
e first way to tackle that is reducing the idle opened connection to zero, and 2nd thing is to reduce the max Idle time to below 5 minutes if you connection reliable never have interuption (IPVS only open connection for 15 minutes then forget about it), or don't allow any idle connectio
How this fix could it be implemented using knex + mysql2 lib?
@ruanitto I already state that you can lower the maxIdle to zero, on the mysql2 config.
You need to do it to make the connection pool doesn't have any idle connection
There are open ticket #2599 that still in motion.
Also, as I state before, your env/network driver could blame for it...
So, for now, the solution via config is to set no idle connection at all. After using the connection, disposed and closed. As Simple as that.
you can add extra config on the connection pool to maxIdle: 0
, if it still not clear for you
Refer to https://sidorares.github.io/node-mysql2/docs#using-connection-pools
Hey all,
Hoping to get some help with this sporadic error I'm seeing with mysql2
Same background info on what I'm using node 20 nestjs 10 typeorm 0.3.20 mysql2 3.9.4
I have 2 nodes running behind a load balancer that do connect over a virtual network tunnel to an on prem server that hosts the Mariadb on version 8.1
Here's my config
I'm getting these random read ETIMEDOUT errors through out the day but can't pin point any specific pattern or reason why it's timing out
I've ran pings from the nodes to the on prem server and didn't see any dropped packets on the on prem network side there was a tiny bit of packet loss on the node side but should be within an ok percentage 1318 packets transmitted, 1317 received, 0.0758725% packet loss, time 1318903ms 1360 packets transmitted, 1354 received, 0.441176% packet loss, time 1361060ms node a had a bit more packet loss
within the time of running the pings there were 2 more ETIMEDOUT errors
I also tried looking at the mysql logs and it's completely empty
Any other troubleshooting steps I could try to help resolve this issue would be greatly appreciated!