diff --git a/src/main/java/com/firebolt/jdbc/connection/FireboltConnection.java b/src/main/java/com/firebolt/jdbc/connection/FireboltConnection.java index 14cfd8096..1129935f8 100644 --- a/src/main/java/com/firebolt/jdbc/connection/FireboltConnection.java +++ b/src/main/java/com/firebolt/jdbc/connection/FireboltConnection.java @@ -417,7 +417,7 @@ public boolean isValid(int timeout) throws SQLException { } try { if (!loginProperties.isSystemEngine()) { - validateConnection(getSessionProperties(), true); + validateConnection(getSessionProperties(), true, true); } return true; } catch (Exception e) { @@ -425,9 +425,13 @@ public boolean isValid(int timeout) throws SQLException { } } - private void validateConnection(FireboltProperties fireboltProperties, boolean ignoreToManyRequestsError) + private void validateConnection(FireboltProperties fireboltProperties, boolean ignoreToManyRequestsError, boolean isInternalRequest) throws SQLException { - try (Statement s = createStatement(fireboltProperties)) { + FireboltProperties propertiesCopy = FireboltProperties.copy(fireboltProperties); + if (isInternalRequest) { + propertiesCopy.addProperty("auto_start_stop_control", "ignore"); + } + try (Statement s = createStatement(propertiesCopy)) { s.execute("SELECT 1"); } catch (Exception e) { // A connection is not invalid when too many requests are being sent. @@ -470,7 +474,7 @@ private synchronized void changeProperty(Consumer properties try { FireboltProperties tmpProperties = FireboltProperties.copy(sessionProperties); propertiesEditor.accept(tmpProperties); - validateConnection(tmpProperties, false); + validateConnection(tmpProperties, false, false); propertiesEditor.accept(sessionProperties); } catch (FireboltException e) { throw e; diff --git a/src/test/java/com/firebolt/jdbc/connection/FireboltConnectionTest.java b/src/test/java/com/firebolt/jdbc/connection/FireboltConnectionTest.java index 7428a4db5..a372e3b98 100644 --- a/src/test/java/com/firebolt/jdbc/connection/FireboltConnectionTest.java +++ b/src/test/java/com/firebolt/jdbc/connection/FireboltConnectionTest.java @@ -336,6 +336,7 @@ void shouldValidateConnectionWhenCallingIsValid() throws SQLException { verify(fireboltStatementService).execute(queryInfoWrapperArgumentCaptor.capture(), propertiesArgumentCaptor.capture(), any()); assertEquals(List.of("SELECT 1"), queryInfoWrapperArgumentCaptor.getAllValues().stream().map(StatementInfoWrapper::getSql).collect(toList())); + assertEquals(Map.of("auto_start_stop_control", "ignore"), propertiesArgumentCaptor.getValue().getAdditionalProperties()); } }