Search code examples
mysqlgrailsgrails-3.3.x

cause of no operations allowed after connection closed error?


I am using grails 3.3.9 to build a sample hello app. When the app is deployed it works fine. When i check after a day or so the app has already crashed. Checking the logs, i see an error "no operations allowed after connection closed.". Looks like at some point the mysql database connection is broken.

enter image description here

enter image description here

Here is the database configuration i am using in application.yml

enter image description here

I appreciate any insight into why does connection to database get closed automatically after a while. How can i prevent it? Thanks for the feedbacks.


Solution

  • I added the following for production and so far the error hasn't recurred.

     properties:
                    jmxEnabled: true
                    initialSize: 5
                    maxActive: 50
                    minIdle: 5
                    maxIdle: 25
                    maxWait: 10000
                    maxAge: 600000
                    timeBetweenEvictionRunsMillis: 5000
                    minEvictableIdleTimeMillis: 60000
                    validationQuery: SELECT 1
                    validationQueryTimeout: 3
                    validationInterval: 15000
                    testOnBorrow: true
                    testWhileIdle: true
                    testOnReturn: false
                    jdbcInterceptors: ConnectionState
                    defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED