From 19946deb82438874e7f3fdc8cd703fc3f202ab72 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Wed, 4 Dec 2024 18:28:05 +0100 Subject: [PATCH] simplify warn_after_seconds --- backend/windmill-common/src/job_metrics.rs | 3 ++- backend/windmill-common/src/utils.rs | 2 +- backend/windmill-queue/src/jobs.rs | 9 ++++++--- backend/windmill-worker/src/worker_flow.rs | 4 +++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/backend/windmill-common/src/job_metrics.rs b/backend/windmill-common/src/job_metrics.rs index c0c2300fed..6577e34d6e 100644 --- a/backend/windmill-common/src/job_metrics.rs +++ b/backend/windmill-common/src/job_metrics.rs @@ -1,4 +1,4 @@ -use crate::{db::DB, error}; +use crate::{db::DB, error, utils::WarnAfterExt}; use serde::{Deserialize, Serialize}; use uuid::Uuid; @@ -90,6 +90,7 @@ pub async fn register_metric_for_job( .bind(timeseries_int) .bind(timeseries_float) .execute(db) + .warn_after_seconds(1) .await?; Ok(metric_id) diff --git a/backend/windmill-common/src/utils.rs b/backend/windmill-common/src/utils.rs index 5dd89f80e1..c13f96e2de 100644 --- a/backend/windmill-common/src/utils.rs +++ b/backend/windmill-common/src/utils.rs @@ -599,7 +599,7 @@ impl Future for WarnAfterFuture { let elapsed = this.start_time.elapsed(); tracing::warn!( location = this.location, - "SLOW QUERY: completed with total duration: {:.2?}", + "SLOW_QUERY: completed with total duration: {:.2?}", elapsed ); } diff --git a/backend/windmill-queue/src/jobs.rs b/backend/windmill-queue/src/jobs.rs index 2390ca47bb..1e516f4821 100644 --- a/backend/windmill-queue/src/jobs.rs +++ b/backend/windmill-queue/src/jobs.rs @@ -39,8 +39,8 @@ use windmill_audit::audit_ee::{audit_log, AuditAuthor}; use windmill_audit::ActionKind; use windmill_common::{ - cache, auth::{fetch_authed_from_permissioned_as, permissioned_as_to_username}, + cache, db::{Authed, UserDB}, error::{self, to_anyhow, Error}, flow_status::{ @@ -57,7 +57,7 @@ use windmill_common::{ schedule::Schedule, scripts::{get_full_hub_script_by_path, ScriptHash, ScriptLang}, users::{SUPERADMIN_NOTIFICATION_EMAIL, SUPERADMIN_SECRET_EMAIL}, - utils::{not_found_if_none, report_critical_error, StripPath}, + utils::{not_found_if_none, report_critical_error, StripPath, WarnAfterExt}, worker::{ to_raw_value, CLOUD_HOSTED, DEFAULT_TAGS_PER_WORKSPACE, DEFAULT_TAGS_WORKSPACES, DISABLE_FLOW_SCRIPT, MIN_VERSION_IS_AT_LEAST_1_427, MIN_VERSION_IS_AT_LEAST_1_432, NO_LOGS, @@ -318,6 +318,7 @@ pub async fn append_logs( workspace.as_ref(), ) .execute(db.borrow()) + .warn_after_seconds(1) .await { tracing::error!(%job_id, %err, "error updating logs for large_log job {job_id}: {err}"); @@ -3227,7 +3228,7 @@ pub async fn push<'c, 'd>( None, None, ) - }, + } JobPayload::ScriptHub { path } => { if path == "hub/7771/slack" || path == "hub/7836/slack" { permissioned_as = SUPERADMIN_NOTIFICATION_EMAIL.to_string(); @@ -3851,6 +3852,7 @@ pub async fn push<'c, 'd>( tag, ) .execute(&mut *tx) + .warn_after_seconds(1) .await?; let (raw_code, raw_lock, raw_flow) = if !*MIN_VERSION_IS_AT_LEAST_1_427.read().await { @@ -3901,6 +3903,7 @@ pub async fn push<'c, 'd>( final_priority, ) .fetch_one(&mut *tx) + .warn_after_seconds(1) .await .map_err(|e| Error::InternalErr(format!("Could not insert into queue {job_id} with tag {tag}, schedule_path {schedule_path:?}, script_path: {script_path:?}, email {email}, workspace_id {workspace_id}: {e:#}")))?; diff --git a/backend/windmill-worker/src/worker_flow.rs b/backend/windmill-worker/src/worker_flow.rs index 1e4aefdba0..050f0ebcf4 100644 --- a/backend/windmill-worker/src/worker_flow.rs +++ b/backend/windmill-worker/src/worker_flow.rs @@ -2137,6 +2137,7 @@ async fn push_next_flow_job( .bind(status.step) .bind(json!(status.retry.failed_jobs)) .execute(db) + .warn_after_seconds(2) .await .context("update flow retry")?; @@ -2562,6 +2563,7 @@ async fn push_next_flow_job( new_job_priority_override, job_perms.as_ref(), ) + .warn_after_seconds(2) .await?; tracing::debug!(id = %flow_job.id, root_id = %job_root, "pushed next flow job: {uuid}"); @@ -2774,7 +2776,7 @@ async fn push_next_flow_job( .execute(&mut *tx) .await?; - tx.commit().await?; + tx.commit().warn_after_seconds(3).await?; tracing::info!(id = %flow_job.id, root_id = %job_root, "all next flow jobs pushed: {uuids:?}"); if continue_on_same_worker {