From 6a5facb6793841ae820a1158080a1d58b64511e0 Mon Sep 17 00:00:00 2001 From: crrow Date: Tue, 31 Mar 2026 12:21:46 +0800 Subject: [PATCH] fix(meta): rollback video status when event publish fails (#242) When VideoUploaded event publish fails after setting status to Processing, roll back the video status to Uploading so the client can retry the request instead of leaving the video permanently stuck. Closes #242 --- crates/meta/src/handlers.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/meta/src/handlers.rs b/crates/meta/src/handlers.rs index 788a5b7..5ad1c58 100644 --- a/crates/meta/src/handlers.rs +++ b/crates/meta/src/handlers.rs @@ -251,6 +251,14 @@ pub async fn mark_uploaded( .await { tracing::warn!("failed to publish VideoUploaded event: {e}"); + + // Roll back status to Uploading so the client can retry the request. + if let Err(rollback_err) = + video_repo::update_status(&state.db, &video_id, VideoStatus::Uploading).await + { + tracing::error!("failed to rollback video status: {rollback_err}"); + } + return error::InternalSnafu { message: format!("failed to publish VideoUploaded event: {e}"), }