mirror of
https://git.asonix.dog/asonix/pict-rs
synced 2024-11-20 11:21:14 +00:00
Greatly improve error information during migration
This commit is contained in:
parent
e6f17cbac6
commit
c8e84b8914
2 changed files with 20 additions and 12 deletions
19
src/lib.rs
19
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
13
src/store.rs
13
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<crate::store::file_store::FileError> 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<crate::store::file_store::FileError> for StoreError {
|
|||
impl From<crate::store::object_store::ObjectError> 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),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue