1

I'm experimenting with lost connections between my java application and my mysql server.

The application and the server are on two different machines and I'm pulling the physical cord between the two.

I'm running netstat -plunta to find out the state of the connection and here is the weird part. I can see the connection in state ESTABLISHED for a very long time after I pull the cord. At least a couple of hours. Is that supposed to be so? When will a connection terminate when no packets can get through?

Both machines are running Linux/Ubuntu. One is 10.04 and one is 11.04.

poige
  • 9,171
  • 2
  • 24
  • 50

1 Answers1

3

Well, as I've already said in my previous attempt to answer your question, the keyword for soultion is "keep-alive". TCP connection can be in idle state (no data flowing) literally forever. Sometimes it's useful and sometimes it's not. So, 2 approaches: application implements some probing traffic periodically or uses TCP's "extension" keep-alive (TCP_KEEPALIVE).

poige
  • 9,171
  • 2
  • 24
  • 50
  • +1 for beating me to it. One thing I'm not sure on, though: If the application is sending data and the TCP layer isn't getting any ACKs back, is it purely the application's responsibility to handle this condition or should the kernel's TCP stack intervene? – SmallClanger Apr 19 '12 at 08:54
  • @SmallClanger, TCP has built-in timers and re-transmit is such one of them. – poige Apr 19 '12 at 09:49
  • This led me in the right direction. I found out that Drizzle connector doesn't support tcp keep alive but that MySQL connector/J does. – Andreas Wederbrand Apr 19 '12 at 17:12