Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Db connection is hung when there is a network change #227

Open
tuliren opened this issue Aug 15, 2018 · 3 comments
Open

Db connection is hung when there is a network change #227

tuliren opened this issue Aug 15, 2018 · 3 comments

Comments

@tuliren
Copy link
Contributor

tuliren commented Aug 15, 2018

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: Allow clients to request the transactor to retry queries #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.
@joshk0
Copy link
Contributor

joshk0 commented Aug 15, 2018 via email

@sidoh
Copy link
Contributor

sidoh commented Aug 15, 2018

@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

@joshk0
Copy link
Contributor

joshk0 commented Aug 15, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants