mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-25 16:02:11 +00:00
backend: do not force get_schedule_opt to be within a transaction (#5019)
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -700,7 +700,7 @@ pub async fn add_completed_job<T: Serialize + Send + Sync + ValidableJson>(
|
||||
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")]
|
||||
|
||||
@@ -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<Option<Schedule>> {
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user