From 27ca417201c99cf6fe0ae5b52a63c0395033e196 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Fri, 3 Apr 2026 13:44:10 -0400 Subject: [PATCH] fix: resolve schedule update deadlock (#8701) * feat: add --main flag to write_latest_ee_ref.sh to point to latest EE main Co-Authored-By: Claude Opus 4.6 (1M context) * fix: resolve schedule update deadlock by fixing lock ordering in edit_schedule Co-Authored-By: Claude Opus 4.6 (1M context) --------- Co-authored-by: Claude Opus 4.6 (1M context) --- backend/windmill-api-schedule/src/lib.rs | 7 +++++-- backend/write_latest_ee_ref.sh | 12 +++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/backend/windmill-api-schedule/src/lib.rs b/backend/windmill-api-schedule/src/lib.rs index 9becc3ed33..aa7b5cb07f 100644 --- a/backend/windmill-api-schedule/src/lib.rs +++ b/backend/windmill-api-schedule/src/lib.rs @@ -417,8 +417,6 @@ async fn edit_schedule( validate_dynamic_skip(&mut tx, &w_id, handler_path).await?; } - clear_schedule(&mut tx, path, &w_id).await?; - let resolved_edited_by = resolve_edited_by(&authed); let resolved_permissioned_as = resolve_permissioned_as( @@ -545,6 +543,11 @@ async fn edit_schedule( .await .map_err(|e| Error::internal_err(format!("updating schedule in {w_id}: {e:#}")))?; + // clear_schedule must come AFTER UPDATE schedule to maintain consistent lock ordering + // (schedule row first, then v2_job_queue) and avoid deadlocks with concurrent operations + // like set_enabled, flow updates, and worker job completions. + clear_schedule(&mut tx, path, &w_id).await?; + audit_log( &mut *tx, &authed, diff --git a/backend/write_latest_ee_ref.sh b/backend/write_latest_ee_ref.sh index 7b18684e3a..25a5cb5651 100755 --- a/backend/write_latest_ee_ref.sh +++ b/backend/write_latest_ee_ref.sh @@ -15,11 +15,17 @@ else echo "Directory not found"; exit 1 fi -# Get the current commit hash -commit_hash=$(git rev-parse HEAD) +# If --main is passed, fetch and use latest main +if [ "$1" = "--main" ]; then + git fetch origin main + commit_hash=$(git rev-parse origin/main) +else + # Get the current commit hash + commit_hash=$(git rev-parse HEAD) +fi # Navigate back to the original directory -cd - || exit +cd - > /dev/null || exit # Write the commit hash to ./ee-repo-ref.txt echo -n "$commit_hash" > ./ee-repo-ref.txt