0

I am using a dropwizard server to serve http requests. This dropwizard application is backed my mysql server for data storage. But when left idle (overnight) it gives a 'broken pipe exception' I did a few things that I thought might help. I set the jdbc url in the yaml file to'autoConnect=true'. I also added a 'checkOnBorrow' property. I have increased the jvm to use 4gb none of these fixes worked. Also the wait_timeout and 'interactive_timeout for mysql serveris set to 8 hours. does this need to more more/less?

Also is there a configuration property that can be set in the dropwizard yaml file? Or in other words how is connection pooling managed in dropwizard?

1 Answer 1

4

The problem:

MySql server has a timeout configured after which it terminates all connections idle in the connection pool. This in my case was the default (8 hrs). However the database connection pool is unaware of the terminated connections in the pool. So when a new request comes in, a dead connection is accessed from teh connection pool which results in a 'Broken Pipe' exception.

Solution: So to fix this, we need to get rid of the dead connections and make the pool aware if the connection it is trying to borrow is a dead connection. This can be achieved by setting the following in the .yml configuration.

checkOnReturn: true

checkWhileIdle: true

checkOnBorrow: true

1
  • Thanks, worked fine for me! but the parameters are checkConnectionOnReturn, checkConnectionWhileIdle and checkConnectionOnBorrow (Dropwizard 0.9.2)
    – Elijun
    Feb 26, 2016 at 22:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.