From 7e1f28071a7d6f3f34df417ea746fc9b5dca5157 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Tue, 20 Aug 2024 16:27:01 +0200 Subject: [PATCH] fix: handle more gracefully worker without tags --- backend/windmill-common/src/worker.rs | 8 ++++++++ backend/windmill-queue/src/jobs.rs | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/backend/windmill-common/src/worker.rs b/backend/windmill-common/src/worker.rs index 4924d1ea8a..9f26d2b5e5 100644 --- a/backend/windmill-common/src/worker.rs +++ b/backend/windmill-common/src/worker.rs @@ -86,6 +86,10 @@ lazy_static::lazy_static! { } pub async fn make_suspended_pull_query(wc: &WorkerConfig) { + if wc.worker_tags.len() == 0 { + tracing::error!("Empty tags in worker tags, skipping"); + return; + } let query = format!( "UPDATE queue SET running = true @@ -114,6 +118,10 @@ pub async fn make_suspended_pull_query(wc: &WorkerConfig) { pub async fn make_pull_query(wc: &WorkerConfig) { let mut queries = vec![]; for tags in wc.priority_tags_sorted.iter() { + if tags.tags.len() == 0 { + tracing::error!("Empty tags in priority tags, skipping"); + continue; + } let query = format!("UPDATE queue SET running = true , started_at = coalesce(started_at, now()) diff --git a/backend/windmill-queue/src/jobs.rs b/backend/windmill-queue/src/jobs.rs index 7e1bf9b192..d1cdb8034a 100644 --- a/backend/windmill-queue/src/jobs.rs +++ b/backend/windmill-queue/src/jobs.rs @@ -1967,6 +1967,11 @@ async fn pull_single_job_and_mark_as_running_no_concurrency_limit< * or suspend_until <= now() if it has timed out */ let query = WORKER_SUSPENDED_PULL_QUERY.read().await; + if query.is_empty() { + tracing::warn!("No suspended pull queries available"); + return Ok(None); + } + let r = if suspend_first { // tracing::info!("Pulling job with query: {}", query); sqlx::query_as::<_, QueuedJob>(&query) @@ -1982,6 +1987,11 @@ async fn pull_single_job_and_mark_as_running_no_concurrency_limit< let queries = WORKER_PULL_QUERIES.read().await; + if queries.is_empty() { + tracing::warn!("No pull queries available"); + return Ok(None); + } + for query in queries.iter() { // tracing::info!("Pulling job with query: {}", query); let r = sqlx::query_as::<_, QueuedJob>(query)