LiveRamp/jack

Db connection is hung when there is a network change

tuliren opened this issue · 3 comments

A db connection will hang when there is a network change. This is because we don't enforce timeout at any level. For detailed explanation, please refer to this article.

There are several ways to fix it:

  1. Specify socket timeout. This is easy to implement (modify connection string), but it is hard to find the optimal value, or to use special setting for legitimate long-running query.
  2. Enforce timeout on transactor. This requires a refactoring of the transactor implementation (relevant PR: #210).
  3. Call isValid before checking out a connection from the pool (modify this method). This approach will only partially solve this problem. Queries that are already running while there is a network change will still suffer from this issue. In addition, currently IDb methods are implemented in each implementation, while many of the methods are the same and can be extracted to a base class. Should we choose this approach, we should consider performing this refactoring as well.
sidoh commented

@joshk0 - I had the same idea, but I think you have the firmer understanding here. It seems like this kind of thing is exactly what SO_KEEPALIVE is intended to solve for. It's also just a JDBC parameter:

https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-configuration-properties.html