Fix #289 fixed issue where a connection that was checked-out, never used for longer than the DB connection timeout, and then returned to the pool could bypass the aliveness check and be given to another caller of getConnection().

pull/323/head
Brett Wooldridge 10 years ago
parent 1cb7de0be7
commit cd457367f7

@ -239,7 +239,6 @@ public abstract class BaseHikariPool implements HikariPoolMBean, IBagStateListen
closeConnection(bagEntry);
}
else {
bagEntry.lastAccess = System.currentTimeMillis();
connectionBag.requite(bagEntry);
}
}

@ -32,11 +32,11 @@ public final class PoolBagEntry implements IConcurrentBagEntry
public final AtomicInteger state = new AtomicInteger();
public Connection connection;
public long lastAccess;
public long lastOpenTime;
public volatile boolean evicted;
public volatile boolean aborted;
protected long lastAccess;
private volatile ScheduledFuture<?> endOfLife;

@ -51,6 +51,7 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
private final PoolBagEntry bagEntry;
private final FastList<Statement> openStatements;
private long lastAccess;
private boolean isCommitStateDirty;
private boolean isConnectionStateDirty;
private boolean isAutoCommitDirty;
@ -76,6 +77,7 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
this.bagEntry = bagEntry;
this.delegate = bagEntry.connection;
this.leakTask = leakTask;
this.lastAccess = bagEntry.lastAccess;
this.openStatements = new FastList<Statement>(Statement.class, 16);
}
@ -128,6 +130,7 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
public final void markCommitStateDirty()
{
isCommitStateDirty = true;
lastAccess = System.currentTimeMillis();
}
// ***********************************************************************
@ -136,6 +139,7 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
private final <T extends Statement> T trackStatement(final T statement)
{
lastAccess = System.currentTimeMillis();
openStatements.add(statement);
return statement;
@ -202,6 +206,7 @@ public abstract class ConnectionProxy implements IHikariConnectionProxy
}
finally {
delegate = ClosedConnection.CLOSED_CONNECTION;
bagEntry.lastAccess = lastAccess;
parentPool.releaseConnection(bagEntry);
}
}

Loading…
Cancel
Save