0

I have been having this error for a while and I do not know what could be causing it.

The thing is that it only happens in production. I have the app deployed to a AWS EC2 container managed by a Beanstalk. The error shows up every few hours; not sure how much.

After searching the web a found a few sources and I changed my data source configuration to this:

  # Configuration needed to keep the JPA entity open
  # Used from here: https://github.com/GluuFederation/message-consumer/issues/4
  # This would be enough: https://github.com/netgloo/spring-boot-samples/blob/master/spring-boot-mysql-springdatajpa-hibernate/src/main/resources/application.properties
  datasource:
    tomcat:
      initial-size: 34
      max-active: 377
      max-idle: 233
      min-idle: 89
      time-between-eviction-runs-millis: 34000
      min-evictable-idle-time-millis: 55000
      validation-query: SELECT 1
      validation-interval: 4000
      test-on-borrow: true
      remove-abandoned: true
      remove-abandoned-timeout: 55

I have checked and I can connect directly to the database using Workbench and I made a few queries without a problem.

Also the AWS container health is good (as far as I know, it's green :))

Any ideas about this?

  • What is the actual exception you are getting? Including Stacktrace. Also please include your code mentioned in the Stacktrace. – Jens Schauder Oct 10 '17 at 04:46
  • Enable `test-while-idle` next to `test-on-borrow` to have broken connection cleaned out while the application is up. See also https://stackoverflow.com/questions/30451470/connection-to-db-dies-after-424-in-spring-boot-jpa-hibernate/30455408#30455408. – M. Deinum Oct 10 '17 at 06:29
  • @M.Deinum I am going to give it a try once I merge the current branch I am working on. I will let you know how it goes. I was also thinking should I switch to Hiraki ? –  Oct 10 '17 at 20:44

1 Answers1

0

After trying a few things and failing. I decided to switch to Hiraki

  datasource:
    type: com.zaxxer.hikari.HikariDataSource
    hikari:
      minimum-idle: 5
      maximum-pool-size: 10
      idle-timeout: 30000
      connection-test-query: SELECT 1

And with this configuration I have not run into any troubles.

I am using the properties provided by a Springboot Hiraki sample repo

https://github.com/netgloo/spring-boot-samples/blob/master/spring-boot-mysql-springdatajpa-hibernate/src/main/resources/application.properties