Random MySQL connections not fully terminated

Hi there,

Recently investigating for dropped traffic in our infrastructure, I have found a few connections on Seafile host, sometimes stuck in “CLOSE_WAIT” status waiting for its last “FIN” packet from a connection that does not exist anymore, thus creating invalid traffic drop.

Beside this, all is working as expected, most SQL connections from Seafile are successfully closed, and nothing linked to mysql issue in Seafile logs (=> nothing is logged when “CLOSE_WAIT” happen). On mysql hosts we can only read in logs an “Aborted connection to db … (Unknown Error)” happenning on ‘ccnet’ and ‘seafile’ databases, this correspond to the few stuck connections from process “seaf-server” and “ccnet-server” on Seafile box.

I’m not able yet to link these stalled connections to any activity from clients or anything. This seems to happen randomly, sometimes no problem for hours, sometimes a few in one hour, but most of the time it happen at day and rarely in the night, makes me think it may be related to clients activity.

On mysql side we have 10min “wait_timeout”, and 128M “max_allowed_packet”, don’t know if it’s important or if Seafile needs tuning on mysql variables.

Config between Seafile and MySQL:

  • Seafile server 6.0.4
  • Docker
  • Haproxy
  • MariaDB Galera Cluster

Thanks again for this awesome work !

Y.

nb: this was happening with Seafile 6.0.3, but I cannot say for v5.

Hi,

This happens because Seafile caches connections to MySQL in a connection pool. Failed connections are not closed until it’s used next time.

How serious is this affecting your service? This should be solved if we add keep alive mechanism to the connection pool.

Hi,

This is not affecting our service at all, yet it only makes a little noise on the network, about 500 drops per day with only 2 active users syncing through windows client.

Good to know there is a fix possible, if you plan to add a keep alive mechanism it will be gladly welcome here ! By the way, if I find some tweaks to reduce or to stop bad traffic I will be happy to share it.

Thanks again.

Y.