diff --git a/ebean-datasource/src/main/java/io/ebean/datasource/pool/PooledConnectionQueue.java b/ebean-datasource/src/main/java/io/ebean/datasource/pool/PooledConnectionQueue.java index e999ce2..20280b4 100644 --- a/ebean-datasource/src/main/java/io/ebean/datasource/pool/PooledConnectionQueue.java +++ b/ebean-datasource/src/main/java/io/ebean/datasource/pool/PooledConnectionQueue.java @@ -225,7 +225,10 @@ private PooledConnection _obtainConnection() throws InterruptedException, SQLExc // or SQLException but that is ok as its only an indicator hitCount++; // are other threads already waiting? (they get priority) - if (waitingThreads == 0) { + if (waitingThreads == 0 + // If datasource is down, we might run into _obtainConnectionWaitLoop forever (or until no thread requests connections), + // in case threads were waiting when reset() occurs. Without this, it would be hard to recover/reconnect the pool. + || busyList.size() < maxSize) { PooledConnection freeConnection = extractFromFreeList(); if (freeConnection != null) { return freeConnection;