From c8e84b8914c603faf1605d7058f7e35066cf4fd2 Mon Sep 17 00:00:00 2001 From: asonix Date: Sun, 2 Jul 2023 21:07:15 -0500 Subject: [PATCH] Greatly improve error information during migration --- src/lib.rs | 19 ++++++++++++------- src/store.rs | 13 ++++++++----- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 34b5482..0988612 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1387,15 +1387,18 @@ where let mut failure_count = 0; while let Err(e) = do_migrate_store(repo, from.clone(), to.clone(), skip_missing_files).await { - tracing::error!("Failed with {}", e.to_string()); - failure_count += 1; + tracing::error!("Migration failed with {}", format!("{e:?}")); - tokio::time::sleep(Duration::from_secs(5)).await; + failure_count += 1; if failure_count >= 50 { tracing::error!("Exceeded 50 errors"); return Err(e); + } else { + tracing::warn!("Retrying migration +{failure_count}"); } + + tokio::time::sleep(Duration::from_secs(3)).await; } Ok(()) @@ -1562,12 +1565,14 @@ where Err(e) => { failure_count += 1; - tokio::time::sleep(Duration::from_secs(5)).await; - - if failure_count > 50 { - tracing::error!("Error migrating file: {}", e.to_string()); + if failure_count > 10 { + tracing::error!("Error migrating file, not retrying"); return Err(e); + } else { + tracing::warn!("Failed moving file. Retrying +{failure_count}"); } + + tokio::time::sleep(Duration::from_secs(3)).await; } } } diff --git a/src/store.rs b/src/store.rs index 1f2307a..553e79e 100644 --- a/src/store.rs +++ b/src/store.rs @@ -18,12 +18,15 @@ pub(crate) enum StoreError { Repo(#[from] crate::repo::RepoError), #[error("Requested file is not found")] - NotFound, + FileNotFound(#[source] std::io::Error), + + #[error("Requested object is not found")] + ObjectNotFound(#[source] crate::store::object_store::ObjectError), } impl StoreError { pub(crate) const fn is_not_found(&self) -> bool { - matches!(self, Self::NotFound) + matches!(self, Self::FileNotFound(_)) || matches!(self, Self::ObjectNotFound(_)) } } @@ -33,7 +36,7 @@ impl From for StoreError { crate::store::file_store::FileError::Io(e) if e.kind() == std::io::ErrorKind::NotFound => { - Self::NotFound + Self::FileNotFound(e) } e => Self::FileStore(e), } @@ -43,10 +46,10 @@ impl From for StoreError { impl From for StoreError { fn from(value: crate::store::object_store::ObjectError) -> Self { match value { - crate::store::object_store::ObjectError::Status( + e @ crate::store::object_store::ObjectError::Status( actix_web::http::StatusCode::NOT_FOUND, _, - ) => Self::NotFound, + ) => Self::ObjectNotFound(e), e => Self::ObjectStore(e), } }