Merge commit '6494eb90696eed4aa08fe0951371cb3c5e93a07d'

* commit '6494eb90696eed4aa08fe0951371cb3c5e93a07d':
  [maven-release-plugin] prepare release HikariCP-1.3.6
  Update change log.
  Remove chatty logging of connection failures, include "last" connection failure in SQL timeout exception.
  Remove chatty logging of connection failures, include "last" connection failure in SQL timeout exception.
  Break if we're failing to create connections and there is nobody waiting anymore.
  merged
  log pool name in warn messages
  Do not set query timeout when user specifies connectionTimeout of 0.
  Do not set query timeout when user specifies connectionTimeout of 0.
  Small tweak to try to fix Javassist/Java8 incompatibility.
  Fix Java8 JavaDoc errors.
pull/77/head
Brett Wooldridge 11 years ago
commit 5b6fb01767

@ -1,5 +1,15 @@
HikariCP Changes
Changes between 1.3.5 and 1.3.6
*) Include connection failure cause in calls to getConnection() that
timeout (due to connection failure). Removed chatty logging.
*) Java8 Compatability fixes.
*) Include pool name in logging messages. Thanks for the contribution
@jaredstehler.
Changes between 1.3.4 and 1.3.5
*) Fixed a regression in the Javassist code generation.

@ -6,7 +6,7 @@
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>1.3.6-SNAPSHOT</version>
<version>1.3.6</version>
<packaging>bundle</packaging>
<name>HikariCP</name>

@ -215,7 +215,7 @@ public class HikariConfig implements HikariConfigMBean
/**
* Set the SQL query to be executed to test the validity of connections. Using
* the JDBC4 {@link Connection.isValid()} method to test connection validity can
* the JDBC4 <code>Connection.isValid()</code> method to test connection validity can
* be more efficient on some databases and is recommended. See
* {@link HikariConfig#setJdbc4ConnectionTest(boolean)}.
*
@ -438,7 +438,7 @@ public class HikariConfig implements HikariConfigMBean
/**
* Currently not supported.
* @param recordMetrics
* @param recordMetrics <code>true</code> if metrics should be recorded
*/
@Deprecated
public void setRecordMetrics(boolean recordMetrics)

@ -112,18 +112,17 @@ public interface HikariConfigMBean
int getMinimumIdle();
/**
* The property controls the minimum number of connections that HikariCP tries to maintain in the pool,
* including both idle and in-use connections. If the connections dip below this value, HikariCP will
* The property controls the minimum number of idle connections that HikariCP tries to maintain in the pool,
* including both idle and in-use connections. If the idle connections dip below this value, HikariCP will
* make a best effort to restore them quickly and efficiently.
*
* @param minPoolSize the minimum number of connections in the pool
* @param minIdle the minimum number of idle connections in the pool to maintain
*/
void setMinimumIdle(int minIdle);
/**
* The property controls the minimum number of connections that HikariCP tries to maintain in the pool,
* including both idle and in-use connections. If the connections dip below this value, HikariCP will
* make a best effort to restore them quickly and efficiently.
* The property controls the maximum number of connections that HikariCP will keep in the pool,
* including both idle and in-use connections.
*
* @return the maximum number of connections in the pool
*/

@ -25,6 +25,7 @@ import java.util.TimerTask;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import javax.sql.DataSource;
@ -73,7 +74,7 @@ public final class HikariPool implements HikariPoolMBean, IBagStateListener
private final String password;
private volatile boolean isShutdown;
private volatile long lastConnectionFailureTime;
private volatile AtomicReference<Throwable> lastConnectionFailure;
private int transactionIsolation;
private boolean isDebug;
@ -97,6 +98,7 @@ public final class HikariPool implements HikariPoolMBean, IBagStateListener
this.connectionBag = new ConcurrentBag<IHikariConnectionProxy>();
this.connectionBag.addBagStateListener(this);
this.isDebug = LOGGER.isDebugEnabled();
this.lastConnectionFailure = new AtomicReference<Throwable>();
this.catalog = configuration.getCatalog();
this.connectionCustomizer = configuration.getConnectionCustomizer();
@ -170,7 +172,7 @@ public final class HikariPool implements HikariPoolMBean, IBagStateListener
while (timeout > 0);
logPoolState("Timeout failure ");
throw new SQLException(String.format("Timeout of %dms encountered waiting for connection.", configuration.getConnectionTimeout()));
throw new SQLException(String.format("Timeout of %dms encountered waiting for connection.", configuration.getConnectionTimeout()), lastConnectionFailure.getAndSet(null));
}
catch (InterruptedException e)
{
@ -198,7 +200,8 @@ public final class HikariPool implements HikariPoolMBean, IBagStateListener
}
else
{
LOGGER.debug("Connection returned to pool is broken, or the pool is shutting down. Closing connection.");
LOGGER.debug("Connection returned to pool {} is broken, or the pool is shutting down. Closing connection.",
configuration.getPoolName());
closeConnection(connectionProxy);
}
}
@ -249,6 +252,11 @@ public final class HikariPool implements HikariPoolMBean, IBagStateListener
{
PoolUtilities.quietlySleep(sleepBackoff);
sleepBackoff = (int) Math.min(1000f, ((float) sleepBackoff) * 1.5);
if (getThreadsAwaitingConnection() == 0)
{
lastConnectionFailure = null;
break;
}
continue;
}
@ -342,6 +350,7 @@ public final class HikariPool implements HikariPoolMBean, IBagStateListener
IHikariConnectionProxy proxyConnection = ProxyFactory.getProxyConnection(this, connection, transactionIsolation, isAutoCommit, isReadOnly, catalog);
proxyConnection.resetConnectionState();
connectionBag.add(proxyConnection);
lastConnectionFailure.set(null);
return true;
}
catch (Exception e)
@ -354,12 +363,11 @@ public final class HikariPool implements HikariPoolMBean, IBagStateListener
PoolUtilities.quietlyCloseConnection(connection);
}
long now = System.currentTimeMillis();
if (now - lastConnectionFailureTime > 1000 || isDebug)
lastConnectionFailure.set(e);
if (isDebug)
{
LOGGER.warn("Connection attempt to database failed (not every attempt is logged): {}", e.getMessage(), (isDebug ? e : null));
LOGGER.warn("Connection attempt to database {} failed (not every attempt is logged): {}", configuration.getPoolName(), e.getMessage(), (isDebug ? e : null));
}
lastConnectionFailureTime = now;
return false;
}
}
@ -386,7 +394,10 @@ public final class HikariPool implements HikariPoolMBean, IBagStateListener
Statement statement = connection.createStatement();
try
{
statement.setQueryTimeout((int) TimeUnit.MILLISECONDS.toSeconds(timeoutMs));
if (configuration.getConnectionTimeout() < Integer.MAX_VALUE)
{
statement.setQueryTimeout((int) TimeUnit.MILLISECONDS.toSeconds(timeoutMs));
}
statement.executeQuery(configuration.getConnectionTestQuery());
}
finally
@ -420,7 +431,7 @@ public final class HikariPool implements HikariPoolMBean, IBagStateListener
{
if (!addConnection())
{
throw new RuntimeException("Fail-fast during pool initialization");
throw new RuntimeException("Fail-fast during pool initialization", lastConnectionFailure.getAndSet(null));
}
}
}
@ -481,7 +492,7 @@ public final class HikariPool implements HikariPoolMBean, IBagStateListener
{
int total = totalConnections.get();
int idle = getIdleConnections();
LOGGER.debug("{}Pool stats (total={}, inUse={}, avail={}, waiting={})", (prefix.length > 0 ? prefix[0] : ""), total, total - idle, idle,
LOGGER.debug("{}Pool stats {} (total={}, inUse={}, avail={}, waiting={})", (prefix.length > 0 ? prefix[0] : ""), configuration.getPoolName(), total, total - idle, idle,
getThreadsAwaitingConnection());
}

@ -141,7 +141,7 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
forceClose |= sqlState.startsWith("08") | SQL_ERRORS.contains(sqlState);
if (forceClose)
{
LOGGER.warn("Connection {} marked as broken because of SQLSTATE({}), ErrorCode({}): {}", delegate.toString(), sqlState, sqle.getErrorCode(), sqle.getNextException());
LOGGER.warn("Connection {} ({}) marked as broken because of SQLSTATE({}), ErrorCode({}): {}", delegate.toString(), parentPool.toString(), sqle.getErrorCode(), sqle.getNextException());
}
else if (sqle.getNextException() instanceof SQLException)
{

@ -192,7 +192,7 @@ public final class JavassistProxyFactory
}
else
{
modifiedBody = "return ((cast) delegate).method($$);".replace("method", method.getName()).replace("cast", primaryInterface.getName());
modifiedBody = "{ return ((cast) delegate).method($$); }".replace("method", method.getName()).replace("cast", primaryInterface.getName());
}
if (method.getReturnType() == CtClass.voidType)

@ -42,7 +42,6 @@ import java.util.concurrent.locks.AbstractQueuedLongSynchronizer;
* @author Brett Wooldridge
*
* @param <T> the templated type to store in the bag
* @param <IBagManagable>
*/
public class ConcurrentBag<T extends com.zaxxer.hikari.util.ConcurrentBag.IBagManagable>
{
@ -72,9 +71,6 @@ public class ConcurrentBag<T extends com.zaxxer.hikari.util.ConcurrentBag.IBagMa
*/
public interface IBagStateListener
{
/**
* @param timeout timeout to add item to bag in milliseconds
*/
void addBagItem();
}
@ -245,7 +241,7 @@ public class ConcurrentBag<T extends com.zaxxer.hikari.util.ConcurrentBag.IBagMa
* reserved can be removed from the bag via {@link #remove(IBagManagable)}
* without the need to unreserve them. Items that are not removed
* from the bag can be make available for borrowing again by calling
* the {@link #unreserve(IBagManagable) method.
* the {@link #unreserve(IBagManagable)} method.
*
* @param value the item to reserve
* @return true if the item was able to be reserved, false otherwise

@ -26,6 +26,7 @@ public final class PoolUtilities
* Execute the user-specified init SQL.
*
* @param connection the connection to initialize
* @param sql the SQL to execute
* @throws SQLException throws if the init SQL execution fails
*/
public static void executeSqlAutoCommit(Connection connection, String sql) throws SQLException

Loading…
Cancel
Save