Hi all.
We are facing a peculiar issue in one of our in-production applications. The application is a single threaded application that when started, connects to database through hibernate, checks some statistics and exits. Lately it has started hanging once in a while when hibernate code starts executing. We are using default hibernate connection pooling which should not really matter becoz in the course of the entire program just one connection is obtained and the database queried and thats it. and the deal is that hibernate hangs while trying to obtain the connection itself. The piece of code where hibernate hangs is from the class org.hibernate.connection.DriverManagerConnectionProvider in the getConnection method which is pasted below. When we look at the logs, the last log statement printed is "opening new JDBC connection". The log statement after that (ie "created connection to: " + url etc ) is not printed at all indicating that hibernate is hanging somewhere in between. We talked to DBA team and they said that it couldn't be because of connection starvation because database seems to have enough resources to allocate and the database side logs/ monitoring has not indicated any such crunch. Can somebody please help in this regard as to what are the potential situations under which this could be happening.
public Connection getConnection() throws SQLException {
if ( log.isTraceEnabled() ) log.trace( "total checked-out connections: " + checkedOut );
synchronized (pool) {
if ( !pool.isEmpty() ) {
int last = pool.size() - 1;
if ( log.isTraceEnabled() ) {
log.trace("using pooled JDBC connection, pool size: " + last);
checkedOut++;
}
Connection pooled = (Connection) pool.remove(last);
if (isolation!=null) pooled.setTransactionIsolation( isolation.intValue() );
if ( pooled.getAutoCommit()!=autocommit ) pooled.setAutoCommit(autocommit);
return pooled;
}
}
log.debug("opening new JDBC connection");
Connection conn = DriverManager.getConnection(url, connectionProps);
if (isolation!=null) conn.setTransactionIsolation( isolation.intValue() );
if ( conn.getAutoCommit()!=autocommit ) conn.setAutoCommit(autocommit);
if ( log.isDebugEnabled() ) {
log.debug( "created connection to: " + url + ", Isolation Level: " + conn.getTransactionIsolation() );
}
if ( log.isTraceEnabled() ) checkedOut++;
return conn;
}
|