Ignore NotFound errors in the syncer (#3131)
This commit is contained in:
parent
b1acdc61b4
commit
a92c431c03
|
|
@ -47,9 +47,6 @@ pub enum PeerError {
|
||||||
#[error("Internal services over capacity")]
|
#[error("Internal services over capacity")]
|
||||||
Overloaded,
|
Overloaded,
|
||||||
|
|
||||||
// TODO: stop closing connections on these errors (#2107)
|
|
||||||
// log info or debug logs instead
|
|
||||||
//
|
|
||||||
/// We requested data that the peer couldn't find.
|
/// We requested data that the peer couldn't find.
|
||||||
#[error("Remote peer could not find items: {0:?}")]
|
#[error("Remote peer could not find items: {0:?}")]
|
||||||
NotFound(Vec<InventoryHash>),
|
NotFound(Vec<InventoryHash>),
|
||||||
|
|
|
||||||
|
|
@ -718,6 +718,7 @@ where
|
||||||
/// from the block downloader and verifier stream.
|
/// from the block downloader and verifier stream.
|
||||||
fn should_restart_sync(e: BlockDownloadVerifyError) -> bool {
|
fn should_restart_sync(e: BlockDownloadVerifyError) -> bool {
|
||||||
match e {
|
match e {
|
||||||
|
// Structural matches
|
||||||
BlockDownloadVerifyError::Invalid(VerifyChainError::Checkpoint(
|
BlockDownloadVerifyError::Invalid(VerifyChainError::Checkpoint(
|
||||||
VerifyCheckpointError::AlreadyVerified { .. },
|
VerifyCheckpointError::AlreadyVerified { .. },
|
||||||
)) => {
|
)) => {
|
||||||
|
|
@ -732,19 +733,29 @@ where
|
||||||
tracing::debug!(error = ?e, "block is already in chain, possibly from a previous sync run, continuing");
|
tracing::debug!(error = ?e, "block is already in chain, possibly from a previous sync run, continuing");
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
BlockDownloadVerifyError::Invalid(VerifyChainError::Block(
|
|
||||||
VerifyBlockError::Commit(ref source),
|
|
||||||
)) if format!("{:?}", source).contains("block is already committed to the state") => {
|
|
||||||
// TODO: improve this by checking the type
|
|
||||||
// https://github.com/ZcashFoundation/zebra/issues/2908
|
|
||||||
tracing::debug!(error = ?e, "block is already committed, possibly from a previous sync run, continuing");
|
|
||||||
false
|
|
||||||
}
|
|
||||||
BlockDownloadVerifyError::CancelledDuringDownload
|
BlockDownloadVerifyError::CancelledDuringDownload
|
||||||
| BlockDownloadVerifyError::CancelledDuringVerification => {
|
| BlockDownloadVerifyError::CancelledDuringVerification => {
|
||||||
tracing::debug!(error = ?e, "block verification was cancelled, continuing");
|
tracing::debug!(error = ?e, "block verification was cancelled, continuing");
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// String matches
|
||||||
|
BlockDownloadVerifyError::Invalid(VerifyChainError::Block(
|
||||||
|
VerifyBlockError::Commit(ref source),
|
||||||
|
)) if format!("{:?}", source).contains("block is already committed to the state") => {
|
||||||
|
// TODO: improve this by checking the type (#2908)
|
||||||
|
tracing::debug!(error = ?e, "block is already committed, possibly from a previous sync run, continuing");
|
||||||
|
false
|
||||||
|
}
|
||||||
|
BlockDownloadVerifyError::DownloadFailed(ref source)
|
||||||
|
if format!("{:?}", source).contains("NotFound") =>
|
||||||
|
{
|
||||||
|
// TODO: improve this by checking the type (#2908)
|
||||||
|
// restart after a certain number of NotFound errors?
|
||||||
|
tracing::debug!(error = ?e, "block was not found, possibly from a peer that doesn't have the block yet, continuing");
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
// download_and_verify downcasts errors from the block verifier
|
// download_and_verify downcasts errors from the block verifier
|
||||||
// into VerifyChainError, and puts the result inside one of the
|
// into VerifyChainError, and puts the result inside one of the
|
||||||
|
|
@ -757,7 +768,9 @@ where
|
||||||
let err_str = format!("{:?}", e);
|
let err_str = format!("{:?}", e);
|
||||||
if err_str.contains("AlreadyVerified")
|
if err_str.contains("AlreadyVerified")
|
||||||
|| err_str.contains("AlreadyInChain")
|
|| err_str.contains("AlreadyInChain")
|
||||||
|
|| err_str.contains("Cancelled")
|
||||||
|| err_str.contains("block is already committed to the state")
|
|| err_str.contains("block is already committed to the state")
|
||||||
|
|| err_str.contains("NotFound")
|
||||||
{
|
{
|
||||||
tracing::error!(?e,
|
tracing::error!(?e,
|
||||||
"a BlockDownloadVerifyError that should have been filtered out was detected, \
|
"a BlockDownloadVerifyError that should have been filtered out was detected, \
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue