From 7eb4b0c66a40d5b49342f9cddcedea252048b45a Mon Sep 17 00:00:00 2001 From: Benjamin Gaidioz Date: Tue, 27 Aug 2024 17:46:27 +0200 Subject: [PATCH] Drop existing retry logic --- .../sql/compiler/SqlConnectionPool.scala | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/sql-compiler/src/main/scala/com/rawlabs/sql/compiler/SqlConnectionPool.scala b/sql-compiler/src/main/scala/com/rawlabs/sql/compiler/SqlConnectionPool.scala index 5f3db48ce..76f8597ae 100644 --- a/sql-compiler/src/main/scala/com/rawlabs/sql/compiler/SqlConnectionPool.scala +++ b/sql-compiler/src/main/scala/com/rawlabs/sql/compiler/SqlConnectionPool.scala @@ -161,19 +161,12 @@ class SqlConnectionPool()(implicit settings: RawSettings) extends RawService wit // No connection available... // Check if we must release connections to make space. - var retries = 10 - while (getTotalActiveConnections() >= maxConnections && retries >= 0) { + if (getTotalActiveConnections() >= maxConnections) { if (!releaseOldestConnection()) { - logger.warn(s"Could not release oldest connection; retry #$retries") + // We could not successfully release any connection, so bail out. + logger.warn(s"Could not release oldest connection") + throw new SQLException("no connections available", "08000") } - retries -= 1 - // (msb) Why do I do this? I don't know; I'm assuming by sleeping we increase the change of successful release. - Thread.sleep(10) - } - - // We could not successfully release any connection, so bail out. - if (getTotalActiveConnections() >= maxConnections) { - throw new SQLException("no connections available", "08000") } // Create a new connection. @@ -298,8 +291,7 @@ class SqlConnectionPool()(implicit settings: RawSettings) extends RawService wit if (retries > 0) { Thread.sleep(retryInterval) retryConnection(retries - 1) - } - else { + } else { throw t } }