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

Remove warning from catch in table exists validation #28288

Conversation

damondouglas
Copy link
Contributor

@damondouglas damondouglas commented Sep 1, 2023

This PR addresses #28080 by refactoring the catch block during BigtableIO table existence validation.


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
    Update CHANGES.md with noteworthy changes.
    If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

@damondouglas damondouglas changed the title Remove warning from catch in table exists validation BigtableIO.Write | Remove warning from catch in table exists validation Sep 1, 2023
@damondouglas damondouglas changed the title BigtableIO.Write | Remove warning from catch in table exists validation Remove warning from catch in table exists validation Sep 1, 2023
@damondouglas damondouglas marked this pull request as ready for review September 1, 2023 23:47
@github-actions
Copy link
Contributor

github-actions bot commented Sep 2, 2023

Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment assign set of reviewers

@damondouglas
Copy link
Contributor Author

assign set of reviewers

@github-actions
Copy link
Contributor

github-actions bot commented Sep 3, 2023

Assigning reviewers. If you would like to opt out of this review, comment assign to next reviewer:

R: @robertwb for label java.
R: @chamikaramj for label io.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

@Abacn
Copy link
Contributor

Abacn commented Sep 6, 2023

from the existing warning message "proceeding" this sounds intended. throw an exception may introduce breaking change R: @mutianf

@github-actions
Copy link
Contributor

github-actions bot commented Sep 6, 2023

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control

} catch (IOException e) {
LOG.warn("Error checking whether table {} exists; proceeding.", tableId, e);
throw new IllegalArgumentException(e);
Copy link
Contributor

@mutianf mutianf Sep 19, 2023

Choose a reason for hiding this comment

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

This is meant to catch exceptions when something went wrong and Bigtable client can't connect to the server. In this case we don't know for sure if the table exist or not (note that when the table doesn't exist the code will throw an error on line 695). So I'm not sure if throwing an exception is the right behavior here. But I don't think this will be a breaking change.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you make the exception more descriptive? Or log the error first? I also think we should re-throw IOException instead of changing it to a IllegalArgumentException because it's not an issue with the argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mutianf Thank you again for your review and comments. Given the following, do you feel comfortable with the code changes?

  1. We cannot throw an IOException as the overridden public void validate(PipelineOptions options) method cannot also throw this IOException. Therefore, we have to use a subclass of the RuntimeException, hence the use of IllegalArgumentException. The other choice would just be a RuntimeException. However, it seems to make sense that the arguments provided led to the Exception thrown.

  2. The BigtableServiceFactory's checkTableExists already provides detail on the tableId and the originating ApiException. Therefore, the throw new IllegalArgumentException(e) would capture these details already.

In summary, I see the following scenarios:

Scenario Exception Message Code Origin
Not Found ApiException Table <> does not exist BigtableServiceFactory.java:206
ApiException "Error checking whether table <> exists" with ApiException details BigtableServiceFactory.java:210

@damondouglas damondouglas merged commit 8031162 into apache:master Sep 29, 2023
18 of 23 checks passed
@damondouglas damondouglas deleted the i-28080/java/BigTableIO/validateTableExists branch September 29, 2023 20:04
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.

3 participants