Skip to content

Commit

Permalink
Reducing verbosity during BWS errors
Browse files Browse the repository at this point in the history
Stacktrace can be retrieved by increasing the log level

Signed-off-by: Jiri Peinlich <jiri.peinlich@gmail.com>
  • Loading branch information
gezero committed Aug 25, 2022
1 parent 98e214c commit 2fd91e5
Showing 1 changed file with 24 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.eth.manager.EthContext;
import org.hyperledger.besu.ethereum.eth.manager.exceptions.NoAvailablePeersException;
import org.hyperledger.besu.ethereum.eth.sync.state.SyncState;
import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
Expand All @@ -36,6 +37,7 @@
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Stream;

Expand Down Expand Up @@ -198,28 +200,28 @@ private CompletableFuture<Void> prepareBackwardSyncFutureWithRetry(final int ret
@VisibleForTesting
protected void processException(final Throwable throwable) {
extractBackwardSyncException(throwable)
.ifPresentOrElse(
backwardSyncException -> {
if (backwardSyncException.shouldRestart()) {
LOG.info(
"Backward sync failed ({}). Current Peers: {}. Retrying in "
+ millisBetweenRetries
+ " milliseconds...",
backwardSyncException.getMessage(),
ethContext.getEthPeers().peerCount());
return;
} else {
debugLambda(
LOG, "Not recoverable backward sync exception {}", throwable::getMessage);
throw backwardSyncException;
}
},
() ->
LOG.warn(
"There was an uncaught exception during Backwards Sync. Retrying in "
+ millisBetweenRetries
+ " milliseconds...",
throwable));
.ifPresentOrElse(
backwardSyncException -> {
if (backwardSyncException.shouldRestart()) {
LOG.info(
"Backward sync failed ({}). Current Peers: {}. Retrying in {} milliseconds...",
throwable.getMessage(),
ethContext.getEthPeers().peerCount(),
millisBetweenRetries);
} else {
debugLambda(
LOG, "Not recoverable backward sync exception {}", throwable::getMessage);
throw backwardSyncException;
}
},
() -> {
LOG.warn(
"Backward sync failed ({}). Current Peers: {}. Retrying in {} milliseconds...",
throwable.getMessage(),
ethContext.getEthPeers().peerCount(),
millisBetweenRetries);
LOG.debug("Exception details:", throwable);
});
}

private Optional<BackwardSyncException> extractBackwardSyncException(final Throwable throwable) {
Expand Down

0 comments on commit 2fd91e5

Please sign in to comment.