org.hibernate.util.JDBCExceptionReporter – Communications link failure | SQL Error: 0, SQLState: 08S01


I noticed an exception like this one in one of our applications’ log and was investigating it. Here’s it:

Exception

[20:26:51] WARN [org.hibernate.util.JDBCExceptionReporter] – SQL Error: 0, SQLState: 08S01
[20:26:51] ERROR [org.hibernate.util.JDBCExceptionReporter] – Communications link failure

Last packet sent to the server was 96429 ms ago.
. . .
org.springframework.dao.DataAccessResourceFailureException: Cannot open connection; nested exception is org.hibernate.exception.JDBCConnectionException: Cannot open connection
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:627)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)

Solution

Seems there was a stale connection at that point of time in Hibernate‘s C3P0 connection pool. MySQL might have timed out the connection, but C3P0 wasn’t probably configured with an appropriate value for idle_test_period and timeout properties, and hence the said connection might have stayed on without getting validated/removed. (The property idle_test_period defines the interval to test unchecked-out connections while timeout is the time unused connections can live in the pool.

If this is a one-off case, there’s no need to worry; just observe this failure over a period of time. If this happens frequently, we may need to double-check the values for above properties.

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 27 other followers

%d bloggers like this: