Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDBC Sources: Wrap SQLTransientException with ConfigErrorException #19711

Merged
merged 15 commits into from
Dec 1, 2022

Conversation

VitaliiMaltsev
Copy link
Contributor

@VitaliiMaltsev VitaliiMaltsev commented Nov 22, 2022

What

Fixes https://app.zenhub.com/workspaces/db--dw-source-connectors-6333360e0a41155061efbcbd/issues/airbytehq/alpha-beta-issues/331

How

Wrap SQLTransientException with ConfigErrorException
mysql-timed-out

🚨 User Impact 🚨

none

Pre-merge Checklist

Expand the relevant checklist and delete the others.

New Connector

Community member or Airbyter

  • Community member? Grant edit access to maintainers (instructions)
  • Secrets in the connector's spec are annotated with airbyte_secret
  • Unit & integration tests added and passing. Community members, please provide proof of success locally e.g: screenshot or copy-paste unit, integration, and acceptance test output. To run acceptance tests for a Python connector, follow instructions in the README. For java connectors run ./gradlew :airbyte-integrations:connectors:<name>:integrationTest.
  • Code reviews completed
  • Documentation updated
    • Connector's README.md
    • Connector's bootstrap.md. See description and examples
    • docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
    • docs/integrations/README.md
    • airbyte-integrations/builds.md
  • PR name follows PR naming conventions

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • If new credentials are required for use in CI, add them to GSM. Instructions.
  • /test connector=connectors/<name> command is passing
  • New Connector version released on Dockerhub by running the /publish command described here
  • After the connector is published, connector added to connector index as described here
  • Seed specs have been re-generated by building the platform and committing the changes to the seed spec files, as described here
Updating a connector

Community member or Airbyter

  • Grant edit access to maintainers (instructions)
  • Secrets in the connector's spec are annotated with airbyte_secret
  • Unit & integration tests added and passing. Community members, please provide proof of success locally e.g: screenshot or copy-paste unit, integration, and acceptance test output. To run acceptance tests for a Python connector, follow instructions in the README. For java connectors run ./gradlew :airbyte-integrations:connectors:<name>:integrationTest.
  • Code reviews completed
  • Documentation updated
    • Connector's README.md
    • Connector's bootstrap.md. See description and examples
    • Changelog updated in docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
  • PR name follows PR naming conventions

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • If new credentials are required for use in CI, add them to GSM. Instructions.
  • /test connector=connectors/<name> command is passing
  • New Connector version released on Dockerhub and connector version bumped by running the /publish command described here
Connector Generator
  • Issue acceptance criteria met
  • PR name follows PR naming conventions
  • If adding a new generator, add it to the list of scaffold modules being tested
  • The generator test modules (all connectors with -scaffold in their name) have been updated with the latest scaffold by running ./gradlew :airbyte-integrations:connector-templates:generator:testScaffoldTemplates then checking in your changes
  • Documentation which references the generator is updated as needed

Tests

Unit

Put your unit tests output here.

Integration

Put your integration tests output here.

Acceptance

Put your acceptance tests output here.

@VitaliiMaltsev VitaliiMaltsev temporarily deployed to more-secrets November 22, 2022 14:04 Inactive
@VitaliiMaltsev VitaliiMaltsev temporarily deployed to more-secrets November 22, 2022 14:04 Inactive
@github-actions
Copy link
Contributor

github-actions bot commented Nov 22, 2022

Affected Connector Report

The latest commit has removed all connector-related changes. There are no more dependent connectors for this PR.

@VitaliiMaltsev VitaliiMaltsev marked this pull request as ready for review November 22, 2022 14:08
@@ -86,6 +86,11 @@ public AirbyteConnectionStatus check(final JsonNode config) throws Exception {
}

return new AirbyteConnectionStatus().withStatus(Status.SUCCEEDED);
} catch (final ConfigErrorException configErrorException) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VitaliiMaltsev VitaliiMaltsev temporarily deployed to more-secrets November 22, 2022 19:25 Inactive
@VitaliiMaltsev VitaliiMaltsev temporarily deployed to more-secrets November 22, 2022 19:26 Inactive
Copy link
Contributor

@akashkulk akashkulk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just a small comment there with respect to removing code from AbstractDbSource.java. Have you been able to test this?

@octavia-squidington-iv octavia-squidington-iv removed the area/connectors Connector related issues label Nov 23, 2022
@VitaliiMaltsev VitaliiMaltsev temporarily deployed to more-secrets November 23, 2022 11:45 Inactive
@VitaliiMaltsev VitaliiMaltsev temporarily deployed to more-secrets November 23, 2022 11:45 Inactive
@VitaliiMaltsev
Copy link
Contributor Author

Looks good! Just a small comment there with respect to removing code from AbstractDbSource.java. Have you been able to test this?

@akashkulk removed unneeded code from AbstractDbSource. Yes, i tested it on my localhost. Please take a look at screenshot in the description of this PR

if (e instanceof SQLTransientException) {
final String message = e.getMessage();
if (message.contains("request timed out")) {
throw new ConfigErrorException("Connection timed out. Unable to contact server.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it's a transient error, I wonder if adding something like "Please try again later" is appropriate,
and also maybe making use of the original e.getMessage() can add valuable information to the user.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it's a transient error, I wonder if adding something like "Please try again later" is appropriate, and also maybe making use of the original e.getMessage() can add valuable information to the user.

@rodireich the connection timeout can be not only because there is some problem with the existing server, but also because if the user pushed the wrong host / port on UI which will also lead to a timeout, so just adding "Please try again later" will be not entirely correct. Might be better to use - "Please check your server settings or try again later". What do you think about it?
Replacing the original e.getMessage() with a more user-friendly one is is a task of this issue. Please see this comment https://github.com/airbytehq/alpha-beta-issues/issues/331#issuecomment-1317496296

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. thank you for explaining!

@VitaliiMaltsev VitaliiMaltsev temporarily deployed to more-secrets November 30, 2022 11:38 Inactive
@octavia-squidington-iv octavia-squidington-iv added the area/connectors Connector related issues label Nov 30, 2022
@VitaliiMaltsev VitaliiMaltsev temporarily deployed to more-secrets November 30, 2022 12:31 Inactive
@VitaliiMaltsev VitaliiMaltsev temporarily deployed to more-secrets November 30, 2022 12:31 Inactive
@VitaliiMaltsev
Copy link
Contributor Author

Looks good! Just a small comment there with respect to removing code from AbstractDbSource.java. Have you been able to test this?

@akashkulk removed unneeded code from AbstractDbSource. Yes, i tested it on my localhost. Please take a look at screenshot in the description of this PR

@akashkulk seems like we can not remove this catch clause cause it will lead to build failing. Please take a look here https://github.com/airbytehq/airbyte/actions/runs/3582926328/jobs/6027754532#step:16:1194

@octavia-squidington-iv octavia-squidington-iv removed the area/connectors Connector related issues label Nov 30, 2022
@VitaliiMaltsev VitaliiMaltsev temporarily deployed to more-secrets November 30, 2022 13:53 Inactive
@VitaliiMaltsev VitaliiMaltsev temporarily deployed to more-secrets November 30, 2022 13:53 Inactive
@akashkulk
Copy link
Contributor

akashkulk commented Nov 30, 2022

How is this breaking the build? I suspect it's related to integration tests failing. The build was also broken earlier this week, so maybe you can update your branch and that will be fixed.

If it's a quick fix - could you remove all exception handling in check() in AbstractDbSource, since it's handled in IntegrationRunner. If not, you can add back the exception handling you had originally had in and the cleanup is tracked by this issue : https://github.com/airbytehq/airbyte-internal-issues/issues/1109.

@@ -79,6 +81,12 @@ public DatabaseMetaData getMetaData() throws SQLException {
final DatabaseMetaData metaData = connection.getMetaData();
return metaData;
} catch (final SQLException e) {
if (e instanceof SQLTransientException) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build error is linting. Make a separate catch statement

Task :airbyte-db:db-lib:pmdMain FAILED
/actions-runner/_work/airbyte/airbyte/airbyte-db/db-lib/src/main/java/io/airbyte/db/jdbc/DefaultJdbcDatabase.java:84: AvoidInstanceofChecksInCatchClause: An instanceof check is being performed on the caught exception. Create a separate catch clause for this exception type.

@VitaliiMaltsev VitaliiMaltsev temporarily deployed to more-secrets December 1, 2022 09:47 Inactive
@VitaliiMaltsev VitaliiMaltsev temporarily deployed to more-secrets December 1, 2022 09:47 Inactive
@VitaliiMaltsev VitaliiMaltsev temporarily deployed to more-secrets December 1, 2022 10:29 Inactive
@VitaliiMaltsev VitaliiMaltsev temporarily deployed to more-secrets December 1, 2022 14:44 Inactive
@VitaliiMaltsev VitaliiMaltsev merged commit 9736352 into master Dec 1, 2022
@VitaliiMaltsev VitaliiMaltsev deleted the vmaltsev/331-mysql-config-error branch December 1, 2022 15:25
@edgao
Copy link
Contributor

edgao commented Dec 2, 2022

is there any risk to reverting this PR? I think it broke the source-postgres and mysql integration tests, e.g. https://github.com/airbytehq/airbyte/actions/runs/3597794993/jobs/6059935439#step:12:3214 (#19985 (comment))

specifically:

  • PostgresJdbcSourceAcceptanceTest.testCheckIncorrectDataBaseFailure is asserting that the message contains State code: 3D000
  • That's no longer the case; the message is now Could not connect with provided configuration. Error: Connection timed out. Unable to contact server. Please check your server settings or try again later
  • The problem is that this condition is always true, because HikariPool wraps everything in a "connect timed out" exception

I verified locally that the test case succeeds after git revert 9736352.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants