Long running queries over tcp don't "respond" to client after completion

Running PS 8.0.22 and I’ve got an issue where when I perform long running queries that don’t produce output (import infile, insert into … select …, etc) the query will complete and then the connection goes idle (mysqladmin processlist on the server shows the connection in a Sleep state) and the client program (perl dbi or mysql command line client) just sit there in a hung state. The crazy part is that if control-c out of the client program the connection to the server drops. I’m banging my head against the wall trying to figure out what causes this issue. If I run the same queries on the local machine (incredibly inconvenient) which I assume is probably connecting over the local socket) this doesn’t occur. Any thoughts?

1 Like

That’s interesting. Can you set log_slow_verbosity=full and capture such example query run via localhost and post it’s slow log entry?
Also, what if you force TCP on local connection (--host=127.0.0.1 --port=3306), does it hung as well?

1 Like

FYI, this ended up being an issue with the idle connection tracker timeout in the GCP firewall (it’s considerably lower than the default keep alive time in linux). The fix was reducing the db servers net.ipv4.tcp_keepalive_time … I set them 5 minutes. You would not believe how much time went into discovering and fixing this issue. :slight_smile: Hopefully this helps someone.

1 Like