Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Improve logging of chain download errors in the pipeline chain downloader #1325

Merged
merged 2 commits into from
Apr 24, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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