Skip to content

Commit

Permalink
fix: Fir 35049 dont reset engine autostop with service queries in dri…
Browse files Browse the repository at this point in the history
…vers for jdbc (#448)
  • Loading branch information
stepansergeevitch authored Jul 30, 2024
1 parent e967a62 commit 9daa67f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -417,17 +417,21 @@ public boolean isValid(int timeout) throws SQLException {
}
try {
if (!loginProperties.isSystemEngine()) {
validateConnection(getSessionProperties(), true);
validateConnection(getSessionProperties(), true, true);
}
return true;
} catch (Exception e) {
return false;
}
}

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.
Expand Down Expand Up @@ -470,7 +474,7 @@ private synchronized void changeProperty(Consumer<FireboltProperties> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down

0 comments on commit 9daa67f

Please sign in to comment.