There is an API which takes more than 10 minutes to process at backend. After some time the database connection is getting timeout resulting in below exception
Caused by: javax.persistence.PersistenceException: com.mysql.cj.jdbc.exceptions.CommunicationsException: The last packet successfully received from the server was 698,467 milliseconds ago. The last packet sent successfully to the server was 698,468 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.
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1692)
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1602)
at org.hibernate.jpa.internal.TransactionImpl.commit(TransactionImpl.java:75)
… 36 common frames omitted
Caused by: com.mysql.cj.jdbc.exceptions.CommunicationsException: The last packet successfully received from the server was 698,467 milliseconds ago. The last packet sent successfully to the server was 698,468 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.
at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64)
at com.mysql.cj.jdbc.ConnectionImpl.commit(ConnectionImpl.java:805)
at com.zaxxer.hikari.pool.ProxyConnection.commit(ProxyConnection.java:352)
at com.zaxxer.hikari.pool.HikariProxyConnection.commit(HikariProxyConnection.java)
at org.hibernate.resource.jdbc.internal.AbstractLogicalConnectionImplementor.commit(AbstractLogicalConnectionImplementor.java:80)
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:232)
at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:65)
at org.hibernate.jpa.internal.TransactionImpl.commit(TransactionImpl.java:61)
… 36 common frames omitted
Below the DB configuration in application.conf:
play.db {
config = “db”
default = “default”
prototype {
# HikariCP configuration options, default values on the right are updated
hikaricp{
connectionTimeout = 300000
leakDetectionThreshold = 290000
}
}
}
db {
default.driver = com.mysql.cj.jdbc.Driver
default.url = #########
default.username = #####
default.db_ip=localhost
default.password=######
default.partitionCount=2
default.maxConnectionsPerPartition=10
default.minConnectionsPerPartition=1
default.idleConnectionTestPeriod=2 minutes
default.initSQL=“SELECT 1”
default.connectionTestStatement=“SELECT 1”
default.logSql=true
default.logStatements=true
default.autocommit=true
default.acquireRetryAttempts=10
default.jndiName=DefaultDS
default.isolation=READ_COMMITTED
default.hikaricp.poolName=“Default”
}
Please suggest me here