Add timeout, metrics back to processor

This commit is contained in:
asonix 2024-03-31 16:34:50 -05:00
parent 056b96d0ad
commit cd6fb84cc4

View file

@ -90,17 +90,17 @@ pub(crate) async fn generate<S: Store + 'static>(
let res = heartbeat(state, hash.clone(), variant.clone(), process_future) let res = heartbeat(state, hash.clone(), variant.clone(), process_future)
.with_poll_timer("heartbeat-future") .with_poll_timer("heartbeat-future")
.await; .with_timeout(Duration::from_secs(state.config.media.process_timeout * 4))
.with_metrics(crate::init_metrics::GENERATE_PROCESS)
.await
.map_err(|_| Error::from(UploadError::ProcessTimeout));
state state
.repo .repo
.notify_variant(hash.clone(), variant.clone()) .notify_variant(hash.clone(), variant.clone())
.await?; .await?;
match res { break res???;
Ok(Ok(tuple)) => break tuple,
Ok(Err(e)) | Err(e) => return Err(e),
}
} }
Err(mut entry) => { Err(mut entry) => {
let notified = entry.notified_timeout(Duration::from_secs(20)); let notified = entry.notified_timeout(Duration::from_secs(20));
@ -110,14 +110,14 @@ pub(crate) async fn generate<S: Store + 'static>(
.variant_identifier(hash.clone(), variant.clone()) .variant_identifier(hash.clone(), variant.clone())
.await? .await?
{ {
drop(notified);
let details = crate::ensure_details_identifier(state, &identifier).await?; let details = crate::ensure_details_identifier(state, &identifier).await?;
break (details, identifier); break (details, identifier);
} }
match notified.await { match notified.await {
Ok(()) => tracing::debug!("notified"), Ok(()) => tracing::debug!("notified"),
Err(_) => tracing::warn!("timeout"), Err(_) => tracing::debug!("timeout"),
} }
attempts += 1; attempts += 1;