Skip to content

Conversation

@chadrik
Copy link
Contributor

@chadrik chadrik commented Aug 15, 2019

Everywhere that we call getInvocation() we should handle the possible StatusException


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

  • Choose reviewer(s) and mention them in a comment (R: @username).
  • Format the pull request title like [BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replace BEAM-XXX with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

Post-Commit Tests Status (on master branch)

Lang SDK Apex Dataflow Flink Gearpump Samza Spark
Go Build Status --- --- Build Status --- --- Build Status
Java Build Status Build Status Build Status Build Status
Build Status
Build Status
Build Status Build Status Build Status
Build Status
Python Build Status
Build Status
Build Status
Build Status
--- Build Status
Build Status
Build Status --- --- Build Status
XLang --- --- --- Build Status --- --- ---

Pre-Commit Tests Status (on master branch)

--- Java Python Go Website
Non-portable Build Status Build Status Build Status Build Status
Portable --- Build Status --- ---

See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.

Everywhere that we call getInvocation() we should handle the possible StatusException
@chadrik
Copy link
Contributor Author

chadrik commented Aug 15, 2019

R: @lukecwik

@chadrik
Copy link
Contributor Author

chadrik commented Aug 15, 2019

Original discussion about this problem is here: #8977 (comment)

Copy link
Member

@lukecwik lukecwik left a comment

Choose a reason for hiding this comment

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

Can you add the try/catch StatusRuntimeException/StatusException to all the other service calls?

GetJobStateResponse response = GetJobStateResponse.newBuilder().setState(state).build();
responseObserver.onNext(response);
responseObserver.onCompleted();
} catch (StatusException e) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
} catch (StatusException e) {
} catch (StatusRuntimeException | StatusException e) {

Here and everywhere else otherwise the catch Exception will also convert the StatusRuntimeException to an INTERNAL status error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated StatusException to StatusRuntimeException | StatusException everywhere, but I'm a bit unclear on what's actually throwing the StatusRuntimeException. I searched the code for StatusRuntimeException and I did not see a clear path from any of those cases to here.

For example, looking at this code I didn't see anything suspicious inside the try/catch block:

  @Override
  public void getState(
      GetJobStateRequest request, StreamObserver<GetJobStateResponse> responseObserver) {
    LOG.trace("{} {}", GetJobStateRequest.class.getSimpleName(), request);
    String invocationId = request.getJobId();
    try {
      JobInvocation invocation = getInvocation(invocationId);
      JobState.Enum state = invocation.getState();
      GetJobStateResponse response = GetJobStateResponse.newBuilder().setState(state).build();
      responseObserver.onNext(response);
      responseObserver.onCompleted();
    } catch (StatusRuntimeException | StatusException e) {
      responseObserver.onError(e);
    } catch (Exception e) {
      String errMessage =
          String.format("Encountered Unexpected Exception for Invocation %s", invocationId);
      LOG.error(errMessage, e);
      responseObserver.onError(Status.INTERNAL.withCause(e).asException());
    }
  }

Copy link
Member

Choose a reason for hiding this comment

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

Since they are runtime exceptions, nothing is required to declare that they are thrown in their method signatures and can propagate up the call stack from any arbitrary location until they hit an appropriately scoped catch statement.

Without the change to also catch the StatusRuntimeException as part of the StatusException, they would be caught as part of the Exception block and converted to INTERNAL errors.

@lukecwik lukecwik merged commit eddaf92 into apache:master Aug 19, 2019
@chadrik chadrik deleted the job-service-status-exception branch September 5, 2019 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants