Too many CLOSE_WAIT connections to backend mysql servers
I am seeing that there are a lot of backend connections to mysql servers lying in CLOSE_WAIT by proxysql.
> netstat -plant | grep -i "close_wait" | grep proxysql | wc -l
3284Example of the connection from lsof:
proxysql 1451 proxysql 8165u IPv4 11226130 0t0 TCP <VM>:37463-><server_ip>:mysql (CLOSE_WAIT)
The above number is at a time when we had already stopped sending any queries/connections to proxysql. This is the connection pool status on proxysql at that moment :
MySQL [(none)]> select * from stats_mysql_connection_pool \G
*************************** 1. row ***************************
hostgroup: 1
srv_host: <write_host>
srv_port: 3306
status: ONLINE
ConnUsed: 0
ConnFree: 10
ConnOK: 186
ConnERR: 0
MaxConnUsed: 11
Queries: 624633
Queries_GTID_sync: 0
Bytes_data_sent: 36748519
Bytes_data_recv: 77792067
Latency_us: 1636
*************************** 2. row ***************************
hostgroup: 2
srv_host: <read_host>
srv_port: 3306
status: SHUNNED
ConnUsed: 0
ConnFree: 0
ConnOK: 642
ConnERR: 7440
MaxConnUsed: 444
Queries: 10724647
Queries_GTID_sync: 0
Bytes_data_sent: 921711388
Bytes_data_recv: 18133451013
Latency_us: 2660
The free connection pct is 1, the max connections for the server is 1000 (I know it is high), the ping interval is 1 sec for backend conns and the wait time out at both mysql server (this is required because of legacy support) and proxysql is 5 sec. As you can see there are no client connections that are open to proxysql and no connections under use but still there are a lot of close_wait connections.
ProxySQL version: ProxySQL version 2.0.12-38-g58a909a, codename Truls OS version: CentOS Linux release 7.5.1804 (Core)
The steps to reproduce the issue: No exact steps that I know of, have encountered this situation first time and this is a setup similar to what we use someplace else. The only issue that I see in the logs is that there are a lot of connection/ping timeouts. But I don't expect that to be the cause of this as I assume that proxysql should be handling that gracefully.
The full ProxySQL error log (default location: /var/lib/proxysql/proxysql.log):
https://drive.google.com/file/d/12oqpd0C2KiVrpS1QfiuaiFScvM10CsfH/view?usp=sharing
Source: sysown/proxysql