Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-15581

Proper business-logic exception propagation from raft listener to client code

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 3.0.0-alpha4
    • None

    Description

      Problem.
      In case of business logic exceptions thrown from within raft listeners it's recommended to use

      clo.result(throwable)
      

      Such throwable is propagated to raft client in ActionResponse container and later on competes client future in common but not an exceptional way (which is a problem):

              return fut.thenApply(resp -> (R) resp.result());
      
          @Override public <R> CompletableFuture<R> run(Command cmd) {
              Peer leader = this.leader;
      
              if (leader == null)
                  return refreshLeader().thenCompose(res -> run(cmd));
      
              ActionRequest req = factory.actionRequest().command(cmd).groupId(groupId).readOnlySafe(true).build();
      
              CompletableFuture<ActionResponse> fut = new CompletableFuture<>();
      
              sendWithRetry(leader, req, currentTimeMillis() + timeout, fut);
      
              return fut.thenApply(resp -> (R) resp.result());
          }
      

      Client future usually have some specific generic type, for example CompletableFuture<Void>, that doesn't match an exception, so client future is completed exceptionally with ClassCastException with the cause of initial server side throwable.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            maliev Mirza Aliev
            alapin Alexander Lapin
            Vladislav Pyatkov Vladislav Pyatkov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 1.5h
                1.5h

                Slack

                  Issue deployment