diff --git a/backend/windmill-api/src/schedule.rs b/backend/windmill-api/src/schedule.rs index 336bc784dc..79e8c4dcb4 100644 --- a/backend/windmill-api/src/schedule.rs +++ b/backend/windmill-api/src/schedule.rs @@ -438,7 +438,7 @@ async fn get_schedule( let path = path.to_path(); let mut tx = user_db.begin(&authed).await?; - let schedule_o = windmill_queue::schedule::get_schedule_opt(&mut tx, &w_id, path).await?; + let schedule_o = windmill_queue::schedule::get_schedule_opt(&mut *tx, &w_id, path).await?; let schedule = not_found_if_none(schedule_o, "Schedule", path)?; tx.commit().await?; Ok(Json(schedule)) diff --git a/backend/windmill-queue/src/jobs.rs b/backend/windmill-queue/src/jobs.rs index aea0096216..a006de4941 100644 --- a/backend/windmill-queue/src/jobs.rs +++ b/backend/windmill-queue/src/jobs.rs @@ -700,7 +700,7 @@ pub async fn add_completed_job( let script_path = queued_job.script_path.as_ref().unwrap(); let schedule = - get_schedule_opt(&mut tx, &queued_job.workspace_id, schedule_path).await?; + get_schedule_opt(&mut *tx, &queued_job.workspace_id, schedule_path).await?; if let Some(schedule) = schedule { #[cfg(feature = "enterprise")] diff --git a/backend/windmill-queue/src/schedule.rs b/backend/windmill-queue/src/schedule.rs index 23e6552f4e..9bb39cc044 100644 --- a/backend/windmill-queue/src/schedule.rs +++ b/backend/windmill-queue/src/schedule.rs @@ -9,7 +9,7 @@ use crate::push; use crate::PushIsolationLevel; use anyhow::Context; -use sqlx::{query_scalar, Postgres, Transaction}; +use sqlx::{query_scalar, PgExecutor, Postgres, Transaction}; use std::collections::HashMap; use std::str::FromStr; use windmill_common::db::Authed; @@ -245,7 +245,7 @@ pub async fn push_scheduled_job<'c>( } pub async fn get_schedule_opt<'c>( - db: &mut Transaction<'c, Postgres>, + e: impl PgExecutor<'c>, w_id: &str, path: &str, ) -> Result> { @@ -254,7 +254,7 @@ pub async fn get_schedule_opt<'c>( ) .bind(path) .bind(w_id) - .fetch_optional(&mut **db) + .fetch_optional(e) .await?; Ok(schedule_opt) } diff --git a/backend/windmill-worker/src/worker_flow.rs b/backend/windmill-worker/src/worker_flow.rs index 40978527da..3feec7830e 100644 --- a/backend/windmill-worker/src/worker_flow.rs +++ b/backend/windmill-worker/src/worker_flow.rs @@ -1510,16 +1510,12 @@ pub async fn handle_flow( && flow_job.script_path.is_some() && status.step == 0 { - let mut tx = db.begin().await?; - let schedule_path = flow_job.schedule_path.as_ref().unwrap(); - let schedule = get_schedule_opt(&mut tx, &flow_job.workspace_id, schedule_path) + let schedule = get_schedule_opt(db, &flow_job.workspace_id, schedule_path) .warn_after_seconds(5) .await?; - tx.commit().await?; - if let Some(schedule) = schedule { if let Err(err) = handle_maybe_scheduled_job( db,