исключение сломанной трубы с MySql в приложении Grails

Я развернул приложение Grails 2.2.1 на удаленном сервере. Через несколько часов, когда я открываю домашнюю страницу приложения, я вижу следующее исключение:

Error 500: Internal Server Error

URI
    /DocGemStudioZoccali/
Class
    java.net.SocketException
Message
    Broken pipe

Trace

    Line | Method
->> 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . in java.lang.Thread

Caused by GroovyPagesException: Error processing GroovyPageView: could not execute query; nested exception is org.hibernate.exception.JDBCConnectionException: could not execute query
->>  631 | runWorker in /index.gsp
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

Caused by DataAccessResourceFailureException: could not execute query; nested exception is org.hibernate.exception.JDBCConnectionException: could not execute query
->>  108 | doCall    in org.grails.datastore.gorm.GormStaticApi$_methodMissing_closure2
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|     25 | doCall    in gsp_docGemStudioZoccaliindex_gsp$_run_closure1
|     38 | run . . . in gsp_docGemStudioZoccaliindex_gsp
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run       in java.lang.Thread

Caused by JDBCConnectionException: could not execute query
->>  108 | doCall    in org.grails.datastore.gorm.GormStaticApi$_methodMissing_closure2
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|     25 | doCall    in gsp_docGemStudioZoccaliindex_gsp$_run_closure1
|     38 | run . . . in gsp_docGemStudioZoccaliindex_gsp
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run       in java.lang.Thread

Caused by CommunicationsException: The last packet successfully received from the server was 138,684,859 milliseconds ago.  The last packet sent successfully to the server was 138,684,859 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
->>  411 | handleNewInstance in com.mysql.jdbc.Util
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1116 | createCommunicationsException in com.mysql.jdbc.SQLError
|   3851 | send . .  in com.mysql.jdbc.MysqlIO
|   2471 | sendCommand in     ''
|   2651 | sqlQueryDirect in     ''
|   2683 | execSQL   in com.mysql.jdbc.ConnectionImpl
|   2144 | executeInternal in com.mysql.jdbc.PreparedStatement
|   2310 | executeQuery in     ''
|     96 | executeQuery in org.apache.commons.dbcp.DelegatingPreparedStatement
|    108 | doCall    in org.grails.datastore.gorm.GormStaticApi$_methodMissing_closure2
|     25 | doCall .  in gsp_docGemStudioZoccaliindex_gsp$_run_closure1
|     38 | run       in gsp_docGemStudioZoccaliindex_gsp
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . in java.lang.Thread

Caused by SocketException: Broken pipe
->>  109 | socketWrite in java.net.SocketOutputStream
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    153 | write     in     ''
|     82 | flushBuffer in java.io.BufferedOutputStream
|    140 | flush     in     ''
|   3832 | send . .  in com.mysql.jdbc.MysqlIO
|   2471 | sendCommand in     ''
|   2651 | sqlQueryDirect in     ''
|   2683 | execSQL   in com.mysql.jdbc.ConnectionImpl
|   2144 | executeInternal in com.mysql.jdbc.PreparedStatement
|   2310 | executeQuery in     ''
|     96 | executeQuery in org.apache.commons.dbcp.DelegatingPreparedStatement
|    108 | doCall    in org.grails.datastore.gorm.GormStaticApi$_methodMissing_closure2
|     25 | doCall .  in gsp_docGemStudioZoccaliindex_gsp$_run_closure1
|     38 | run       in gsp_docGemStudioZoccaliindex_gsp
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . in java.lang.Thread

Я попытался решить проблему, как видно из другого вопроса в SO, но у меня это не работает.

Вот что я сделал внутри конфигурационного файла:

dataSource {
        dbCreate = "update"
        url = "jdbc:mysql://urlofapp/myappname?useUnicode=yes&characterEncoding=UTF-8"
        username = "root"
        password = "root"
        //run the evictor every 30 minutes and evict any connections older than 30 minutes.
        minEvictableIdleTimeMillis=1800000
        timeBetweenEvictionRunsMillis=1800000
        numTestsPerEvictionRun=3
        //test the connection while its idle, before borrow and return it
        testOnBorrow=true
        testWhileIdle=true
        testOnReturn=true
        validationQuery="SELECT 1"
    }

Обратите внимание: если я обновляю страницу, все работает правильно. Кто-нибудь знает что-нибудь, чтобы решить эту проблему?

ИЗМЕНИТЬ 1:

Я отредактировал файл my.cnf в папке /etc, добавив следующее:

wait_timeout = 28800
interactive_timeout = 28800

но ничего не меняется

ИЗМЕНИТЬ 2:

Это фактический источник данных, который я использую. Сломанная труба все еще появляется

dataSource {
   dbCreate = "update"
   url = "jdbc:mysql://urlofapp/myappname?useUnicode=yes&characterEncoding=UTF-8&autoReconnect=true"
   username = "root"
   password = "root"
   minIdle = 5
   maxIdle = 25
   maxWait = 10000
   maxAge = 10 * 60000
   timeBetweenEvictionRunsMillis = 5000
   minEvictableIdleTimeMillis = 60000
   validationQuery = "SELECT 1"
   validationQueryTimeout = 3
   validationInterval = 15000
   testOnBorrow = true
   testWhileIdle = true
   testOnReturn = false
   jdbcInterceptors = "ConnectionState;StatementCache(max=200)"
   defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED
}

ИЗМЕНИТЬ 3:

Вот трассировка стека после предложения Джеймса Клиха

2015-12-04 17:41:36,924 [http-bio-8080-exec-63] ERROR context.GrailsContextLoader  - Error initializing the application: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Cannot resolve reference to bean 'dataSourceUnproxied' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'maxAge' of bean class [org.apache.commons.dbcp.BasicDataSource]: Bean property 'maxAge' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Cannot resolve reference to bean 'dataSourceUnproxied' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'maxAge' of bean class [org.apache.commons.dbcp.BasicDataSource]: Bean property 'maxAge' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:722)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Cannot resolve reference to bean 'dataSourceUnproxied' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'maxAge' of bean class [org.apache.commons.dbcp.BasicDataSource]: Bean property 'maxAge' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
        ... 3 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Cannot resolve reference to bean 'dataSourceUnproxied' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'maxAge' of bean class [org.apache.commons.dbcp.BasicDataSource]: Bean property 'maxAge' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
        ... 3 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Cannot resolve reference to bean 'dataSourceUnproxied' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'maxAge' of bean class [org.apache.commons.dbcp.BasicDataSource]: Bean property 'maxAge' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
        ... 3 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'maxAge' of bean class [org.apache.commons.dbcp.BasicDataSource]: Bean property 'maxAge' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
        ... 3 more
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'maxAge' of bean class [org.apache.commons.dbcp.BasicDataSource]: Bean property 'maxAge' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
        ... 3 more
2015-12-04 17:41:36,931 [http-bio-8080-exec-63] ERROR context.GrailsContextLoader  - Error initializing Grails: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Cannot resolve reference to bean 'dataSourceUnproxied' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'maxAge' of bean class [org.apache.commons.dbcp.BasicDataSource]: Bean property 'maxAge' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Cannot resolve reference to bean 'dataSourceUnproxied' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'maxAge' of bean class [org.apache.commons.dbcp.BasicDataSource]: Bean property 'maxAge' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:722)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Cannot resolve reference to bean 'dataSourceUnproxied' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'maxAge' of bean class [org.apache.commons.dbcp.BasicDataSource]: Bean property 'maxAge' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
        ... 3 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Cannot resolve reference to bean 'dataSourceUnproxied' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'maxAge' of bean class [org.apache.commons.dbcp.BasicDataSource]: Bean property 'maxAge' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
        ... 3 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Cannot resolve reference to bean 'dataSourceUnproxied' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'maxAge' of bean class [org.apache.commons.dbcp.BasicDataSource]: Bean property 'maxAge' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
        ... 3 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'maxAge' of bean class [org.apache.commons.dbcp.BasicDataSource]: Bean property 'maxAge' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
        ... 3 more
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'maxAge' of bean class [org.apache.commons.dbcp.BasicDataSource]: Bean property 'maxAge' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
        ... 3 more
Dec 04, 2015 5:41:36 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Dec 04, 2015 5:41:36 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/DocGemStudioTest] startup failed due to previous errors
2015-12-04 17:41:36,955 [http-bio-8080-exec-63] WARN  lifecycle.ShutdownOperations  - Error occurred running shutdown operation: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:722)
Dec 04, 2015 5:41:36 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [/DocGemStudioTest] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.

ИЗМЕНИТЬ 4:

Я отредактировал блок properties и теперь приложение запускается. Мне нужно проверить, не возникает ли ошибка через несколько часов.

 properties{
                 minIdle = 5
                 maxIdle = 25
                 maxWait = 10000

                 timeBetweenEvictionRunsMillis = 5000
                 minEvictableIdleTimeMillis = 60000
                 validationQuery = "SELECT 1"
                 validationQueryTimeout = 3

                 testOnBorrow = true
                 testWhileIdle = true
                 testOnReturn = false

                 defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED
        }

person FrancescoDS    schedule 28.07.2015    source источник
comment
Вы намеренно оставили urlofapp / myappname? в URL-адресе источника данных, чтобы скрыть его для этого вопроса? Или это проблема вырезания и вставки?   -  person dspano    schedule 28.07.2015
comment
Я использую urlofapp / myappname вместо настоящих имен только для вопроса, очевидно   -  person FrancescoDS    schedule 28.07.2015
comment
Ваш экземпляр mysql принимает подключения с удаленного сервера? вы меняли настройки по умолчанию?   -  person Feras Odeh    schedule 28.07.2015
comment
Да, соединение работает правильно. Я вижу исключение через несколько часов после последнего подключения ... в приведенном выше исключении это похоже на 38 часов   -  person FrancescoDS    schedule 28.07.2015
comment
Вот ссылка на то, что звучит как та же проблема: stackoverflow.com/questions/23102747/   -  person dspano    schedule 28.07.2015
comment
dspano спасибо. Теперь я добавил maxAge = 180000 testOnBorrow = true testWhileIdle = true и посмотрим, что произойдет.   -  person FrancescoDS    schedule 28.07.2015
comment
добавьте &autoReconnect=true или &autoReconnect=yes в URL-адрес подключения к БД   -  person injecteer    schedule 28.07.2015
comment
похоже, тоже не работает ... Я добавил & autoReconnect = true, но он не работает   -  person FrancescoDS    schedule 27.10.2015
comment
Ваше приложение Grails и сервер MySQL находятся на двух разных машинах?   -  person Shashank Agrawal    schedule 04.12.2015
comment
нет, они находятся на одном сервере   -  person FrancescoDS    schedule 04.12.2015


Ответы (4)


Поэтому я считаю, что все, кроме dbCreate, url, username и password, должно быть в блоке свойств:

dataSource {
    dbCreate = "update"
    url = "jdbc:mysql://urlofapp/myappname?useUnicode=yes&characterEncoding=UTF-8&autoReconnect=true"
    username = "root"
    password = "root"
    properties {
        minIdle = 5
        maxIdle = 25
        maxWait = 10000
        maxAge = 10 * 60000
        timeBetweenEvictionRunsMillis = 5000
        minEvictableIdleTimeMillis = 60000
        validationQuery = "SELECT 1"
        validationQueryTimeout = 3
        validationInterval = 15000
        testOnBorrow = true
        testWhileIdle = true
        testOnReturn = false
        jdbcInterceptors = "ConnectionState;StatementCache(max=200)"
        defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED
    }
}
person James Kleeh    schedule 03.12.2015
comment
Я постараюсь и дам вам знать. - person FrancescoDS; 04.12.2015
comment
При добавлении блока свойств приложение не запускается - person FrancescoDS; 04.12.2015
comment
Это должен быть правильный ответ. Вы получаете сообщение об ошибке, когда он не запускается? ValidateionQuery - это свойства, которые помогают поддерживать сеанс в рабочем состоянии. - person stenix; 04.12.2015
comment
Вы также можете изменить параметр interactive_timeout в MySql, но вы, вероятно, не захотите идти по этому пути. Лучше иметь validationQuery, который запускается время от времени, чтобы поддерживать соединение. - person stenix; 04.12.2015
comment
@stenix Я разместил трассировку стека. Единственное, что я заметил, касается maxAge ... в чем может быть проблема? - person FrancescoDS; 04.12.2015
comment
@FrancescoDS удалить свойство maxAge - person James Kleeh; 06.12.2015

Хотя это должно быть странно, но если приложение Grails и сервер MySQL находятся на одном компьютере, используйте localhost или 127.0.0. вместо реального IP-адреса xxx.xxx.xxx.xxx

dataSource {
   dbCreate = "update"
   url = "jdbc:mysql://localhost:3306/docgem_test_db?useUnicode=yes&characterEncoding=UTF-8&autoReconnect=true"
   // Your other properties
}
person Shashank Agrawal    schedule 08.12.2015
comment
@FrancescoDS Сначала я не понял, что вы автор самого вопроса, пытаясь удалить свой IP из сообщения, но позже я принял ваше изменение. Но я просто хочу предупредить вас, что ваш реальный IP-адрес все еще отображается в истории редактирования моего ответа, поэтому подумайте о добавлении дополнительной безопасности, если на вашем IP-адресе есть ваше производственное приложение, или попробуйте изменить его, если это возможно. (Я тоже удалю этот комментарий). - person Shashank Agrawal; 30.08.2016

Пожалуйста, попробуйте следующее, а не добавление driverClassName и dialect, и я также добавил pooled на случай, если вам это нужно

dataSource {
    pooled = true
    driverClassName = "com.mysql.jdbc.Driver"
    dialect = "org.hibernate.dialect.MySQL5InnoDBDialect"
    dbCreate = "update"
    url = "jdbc:mysql://urlofapp/myappname? useUnicode=yes&characterEncoding=UTF-8&autoReconnect=true"
    username = "root"
    password = "root"
    properties {
        minIdle = 5
        maxIdle = 25
        maxWait = 10000
        maxAge = 10 * 60000
        timeBetweenEvictionRunsMillis = 5000
        minEvictableIdleTimeMillis = 60000
        validationQuery = "SELECT 1"
        validationQueryTimeout = 3
        validationInterval = 15000
        testOnBorrow = true
        testWhileIdle = true
        testOnReturn = false
        jdbcInterceptors = "ConnectionState;StatementCache(max=200)"
       defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED
}

}

person DavidC    schedule 10.12.2015

Мне кажется, что у MySQL истекает время ожидания подключения к вам. Наверное, с этим мало что можно поделать.

Можете ли вы рассмотреть вопрос о закрытии соединения, если какое-то время на нем нет трафика, а затем повторно открыть его, когда он снова понадобится?

person Paul Hanchett    schedule 19.11.2015
comment
Что ты имеешь в виду? Ты имеешь в виду, что по-другому решить нельзя? - person FrancescoDS; 20.11.2015
comment
Я говорю, что похоже, что тайм-аут происходит на стороне MySQL соединения. Если вы не контролируете конфигурацию MySQL, вы можете мало что поделать, кроме как изменить ваш подход к тому, как вы обрабатываете соединение. По сути, это тот же ответ, который дал вам Стеникс 4 декабря 2015 года. - person Paul Hanchett; 02.09.2016