Skip to content

Commit

Permalink
add log for unexpected pipeline error (hyperledger#5795)
Browse files Browse the repository at this point in the history
Signed-off-by: Karim TAAM <[email protected]>
  • Loading branch information
matkt authored Aug 25, 2023
1 parent 21dff15 commit d0391ed
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

import static java.util.concurrent.CompletableFuture.completedFuture;

import org.hyperledger.besu.services.pipeline.exception.AsyncOperationException;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -83,7 +85,7 @@ private void outputNextCompletedTask(final WritePipe<O> outputPipe) {
} catch (final InterruptedException e) {
LOG.trace("Interrupted while waiting for processing to complete", e);
} catch (final ExecutionException e) {
throw new RuntimeException("Async operation failed. " + e.getMessage(), e);
throw new AsyncOperationException("Async operation failed. " + e.getMessage(), e);
} catch (final TimeoutException e) {
// Ignore and go back around the loop.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@

import static java.util.stream.Collectors.toList;

import org.hyperledger.besu.services.pipeline.exception.AsyncOperationException;
import org.hyperledger.besu.util.ExceptionUtils;

import java.util.Collection;
import java.util.List;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicBoolean;
Expand Down Expand Up @@ -169,7 +171,13 @@ private Future<?> runWithErrorHandling(final ExecutorService executorService, fi
if (tracingEnabled) {
taskSpan.setStatus(StatusCode.ERROR);
}
LOG.debug("Unhandled exception in pipeline. Aborting.", t);
if (t instanceof CompletionException
|| t instanceof CancellationException
|| t instanceof AsyncOperationException) {
LOG.debug("Unhandled exception in pipeline. Aborting.", t);
} else {
LOG.info("Unexpected exception in pipeline. Aborting.", t);
}
try {
abort(t);
} catch (final Throwable t2) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright Hyperledger Besu Contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.services.pipeline.exception;

/** This class allows throwing an exception in case of failure of an async task in the pipeline */
public class AsyncOperationException extends RuntimeException {

/**
* Constructor of the exception that takes the message and the cause of it.
*
* @param message of the exception
* @param cause of the exception
*/
public AsyncOperationException(final String message, final Throwable cause) {
super(message, cause);
}
}

0 comments on commit d0391ed

Please sign in to comment.