simplify warn_after_seconds

This commit is contained in:
Ruben Fiszel
2024-12-04 18:28:05 +01:00
parent 715d09c30d
commit 19946deb82
4 changed files with 12 additions and 6 deletions
+2 -1
View File
@@ -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)
+1 -1
View File
@@ -599,7 +599,7 @@ impl<F: Future> Future for WarnAfterFuture<F> {
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
);
}
+6 -3
View File
@@ -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:#}")))?;
+3 -1
View File
@@ -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 {