Skip to content

Commit

Permalink
Improve logging of chain download errors in the pipeline chain downlo…
Browse files Browse the repository at this point in the history
…ader. (PegaSysEng#1325)
  • Loading branch information
ajsutton authored and notlesh committed Apr 24, 2019
1 parent 2871e92 commit baccba9
Showing 1 changed file with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
import static tech.pegasys.pantheon.util.FutureUtils.exceptionallyCompose;

import tech.pegasys.pantheon.ethereum.eth.manager.EthScheduler;
import tech.pegasys.pantheon.ethereum.eth.manager.exceptions.EthTaskException;
import tech.pegasys.pantheon.ethereum.eth.sync.state.SyncState;
import tech.pegasys.pantheon.ethereum.eth.sync.state.SyncTarget;
import tech.pegasys.pantheon.ethereum.eth.sync.tasks.exceptions.InvalidBlockException;
import tech.pegasys.pantheon.metrics.Counter;
import tech.pegasys.pantheon.metrics.LabelledMetric;
import tech.pegasys.pantheon.metrics.MetricCategory;
Expand Down Expand Up @@ -112,19 +114,30 @@ private CompletionStage<Void> repeatUnlessDownloadComplete(

private CompletionStage<Void> handleFailedDownload(final Throwable error) {
pipelineErrorCounter.inc();
final Throwable rootCause = ExceptionUtils.rootCause(error);
if (!cancelled.get()
&& syncTargetManager.shouldContinueDownloading()
&& !(rootCause instanceof CancellationException)) {
LOG.debug("Chain download failed. Restarting after short delay.", error);
&& !(ExceptionUtils.rootCause(error) instanceof CancellationException)) {
logDownloadFailure("Chain download failed. Restarting after short delay.", error);
// Allowing the normal looping logic to retry after a brief delay.
return scheduler.scheduleFutureTask(() -> completedFuture(null), PAUSE_AFTER_ERROR_DURATION);
}
LOG.debug("Chain download failed.", error);
logDownloadFailure("Chain download failed.", error);
// Propagate the error out, terminating this chain download.
return completedExceptionally(error);
}

private void logDownloadFailure(final String message, final Throwable error) {
final Throwable rootCause = ExceptionUtils.rootCause(error);
if (rootCause instanceof CancellationException || rootCause instanceof InterruptedException) {
LOG.trace(message, error);
} else if (rootCause instanceof EthTaskException
|| rootCause instanceof InvalidBlockException) {
LOG.debug(message, error);
} else {
LOG.error(message, error);
}
}

private synchronized CompletionStage<Void> startDownloadForSyncTarget(final SyncTarget target) {
if (cancelled.get()) {
return completedExceptionally(new CancellationException("Chain download was cancelled"));
Expand Down

0 comments on commit baccba9

Please sign in to comment.