exclude schedule-triggered jobs from stale job cancellation (#8025)

* fix: exclude schedule-triggered jobs from stale job cancellation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* all

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Ruben Fiszel
2026-02-20 07:49:48 +01:00
committed by GitHub
parent 4abe589397
commit 3e4cad5f70
21 changed files with 46 additions and 69 deletions
@@ -43,7 +43,8 @@
"aiagent",
"unassigned_script",
"unassigned_flow",
"unassigned_singlestepflow"
"unassigned_singlestepflow",
"snapshotbuild"
]
}
}
@@ -42,7 +42,8 @@
"aiagent",
"unassigned_script",
"unassigned_flow",
"unassigned_singlestepflow"
"unassigned_singlestepflow",
"snapshotbuild"
]
}
}
@@ -38,7 +38,8 @@
"aiagent",
"unassigned_script",
"unassigned_flow",
"unassigned_singlestepflow"
"unassigned_singlestepflow",
"snapshotbuild"
]
}
}
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "SELECT v2_job_queue.id, v2_job.tag, v2_job_queue.scheduled_for, v2_job_queue.workspace_id FROM v2_job_queue LEFT JOIN v2_job ON v2_job_queue.id = v2_job.id WHERE running = false AND scheduled_for < now() - ($1 || ' minutes')::interval",
"query": "SELECT v2_job_queue.id, v2_job.tag, v2_job_queue.scheduled_for, v2_job_queue.workspace_id FROM v2_job_queue LEFT JOIN v2_job ON v2_job_queue.id = v2_job.id WHERE running = false AND scheduled_for < now() - ($1 || ' minutes')::interval AND v2_job.trigger_kind IS DISTINCT FROM 'schedule'::job_trigger_kind",
"describe": {
"columns": [
{
@@ -36,5 +36,5 @@
false
]
},
"hash": "b45e17ad532a23b394226c9a5d7ab5a21e20202dbbf9c67831cc62eb067cd2ba"
"hash": "53648c069749df45c0459d733b3e429af20c69c841fb0c3bceafe3ea6c3f5329"
}
@@ -77,7 +77,8 @@
"aiagent",
"unassigned_script",
"unassigned_flow",
"unassigned_singlestepflow"
"unassigned_singlestepflow",
"snapshotbuild"
]
}
}
@@ -44,7 +44,8 @@
"aiagent",
"unassigned_script",
"unassigned_flow",
"unassigned_singlestepflow"
"unassigned_singlestepflow",
"snapshotbuild"
]
}
}
@@ -42,7 +42,8 @@
"aiagent",
"unassigned_script",
"unassigned_flow",
"unassigned_singlestepflow"
"unassigned_singlestepflow",
"snapshotbuild"
]
}
}
@@ -102,7 +102,8 @@
"aiagent",
"unassigned_script",
"unassigned_flow",
"unassigned_singlestepflow"
"unassigned_singlestepflow",
"snapshotbuild"
]
}
}
@@ -32,7 +32,8 @@
"aiagent",
"unassigned_script",
"unassigned_flow",
"unassigned_singlestepflow"
"unassigned_singlestepflow",
"snapshotbuild"
]
}
}
@@ -72,7 +72,8 @@
"aiagent",
"unassigned_script",
"unassigned_flow",
"unassigned_singlestepflow"
"unassigned_singlestepflow",
"snapshotbuild"
]
}
}
@@ -77,7 +77,8 @@
"aiagent",
"unassigned_script",
"unassigned_flow",
"unassigned_singlestepflow"
"unassigned_singlestepflow",
"snapshotbuild"
]
}
}
@@ -102,7 +102,8 @@
"aiagent",
"unassigned_script",
"unassigned_flow",
"unassigned_singlestepflow"
"unassigned_singlestepflow",
"snapshotbuild"
]
}
}
@@ -72,7 +72,8 @@
"aiagent",
"unassigned_script",
"unassigned_flow",
"unassigned_singlestepflow"
"unassigned_singlestepflow",
"snapshotbuild"
]
}
}
@@ -41,7 +41,8 @@
"aiagent",
"unassigned_script",
"unassigned_flow",
"unassigned_singlestepflow"
"unassigned_singlestepflow",
"snapshotbuild"
]
}
}
@@ -41,7 +41,8 @@
"aiagent",
"unassigned_script",
"unassigned_flow",
"unassigned_singlestepflow"
"unassigned_singlestepflow",
"snapshotbuild"
]
}
}
@@ -31,7 +31,8 @@
"aiagent",
"unassigned_script",
"unassigned_flow",
"unassigned_singlestepflow"
"unassigned_singlestepflow",
"snapshotbuild"
]
}
}
@@ -37,7 +37,8 @@
"aiagent",
"unassigned_script",
"unassigned_flow",
"unassigned_singlestepflow"
"unassigned_singlestepflow",
"snapshotbuild"
]
}
}
@@ -77,7 +77,8 @@
"aiagent",
"unassigned_script",
"unassigned_flow",
"unassigned_singlestepflow"
"unassigned_singlestepflow",
"snapshotbuild"
]
}
}
@@ -32,7 +32,8 @@
"aiagent",
"unassigned_script",
"unassigned_flow",
"unassigned_singlestepflow"
"unassigned_singlestepflow",
"snapshotbuild"
]
}
}
+7 -4
View File
@@ -39,8 +39,6 @@ use windmill_common::ee_oss::{jobs_waiting_alerts, worker_groups_alerts};
#[cfg(feature = "oauth2")]
use windmill_common::global_settings::OAUTH_SETTING;
#[cfg(feature = "parquet")]
use windmill_object_store::reload_object_store_setting;
use windmill_common::{
agent_workers::DECODED_AGENT_TOKEN,
apps::APP_WORKSPACED_ROUTE,
@@ -84,6 +82,8 @@ use windmill_common::{
OTEL_METRICS_ENABLED, OTEL_TRACING_ENABLED, SERVICE_LOG_RETENTION_SECS,
};
use windmill_common::{client::AuthedClient, global_settings::APP_WORKSPACED_ROUTE_SETTING};
#[cfg(feature = "parquet")]
use windmill_object_store::reload_object_store_setting;
use windmill_queue::{cancel_job, get_queued_job_v2, SameWorkerPayload};
use windmill_worker::{
result_processor::handle_job_error, JobCompletedSender, JobIsolationLevel,
@@ -1204,7 +1204,10 @@ async fn delete_log_files_from_disk_and_store(
#[cfg(feature = "parquet")]
if _should_del_from_store {
if let Some(os) = _os2 {
let p = windmill_object_store::object_store_reexports::Path::from(format!("{}{}", _s3_prefix, path));
let p = windmill_object_store::object_store_reexports::Path::from(format!(
"{}{}",
_s3_prefix, path
));
if let Err(e) = os.delete(&p).await {
tracing::error!("Failed to delete from object store {}: {e}", p.to_string())
} else {
@@ -2341,7 +2344,7 @@ pub async fn reload_base_url_setting(conn: &Connection) -> error::Result<()> {
async fn stale_job_cancellation(db: &Pool<Postgres>) {
if let Some(threshold) = *STALE_JOB_THRESHOLD_MINUTES {
let stale_jobs = sqlx::query!(
"SELECT v2_job_queue.id, v2_job.tag, v2_job_queue.scheduled_for, v2_job_queue.workspace_id FROM v2_job_queue LEFT JOIN v2_job ON v2_job_queue.id = v2_job.id WHERE running = false AND scheduled_for < now() - ($1 || ' minutes')::interval",
"SELECT v2_job_queue.id, v2_job.tag, v2_job_queue.scheduled_for, v2_job_queue.workspace_id FROM v2_job_queue LEFT JOIN v2_job ON v2_job_queue.id = v2_job.id WHERE running = false AND scheduled_for < now() - ($1 || ' minutes')::interval AND v2_job.trigger_kind IS DISTINCT FROM 'schedule'::job_trigger_kind",
threshold.to_string()
)
.fetch_all(db)
+1 -45
View File
@@ -835,7 +835,6 @@
"version": "1.7.1",
"resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.7.1.tgz",
"integrity": "sha512-o1uhUASyo921r2XtHYOHy7gdkGLge8ghBEQHMWmyJFoXlpU58kIrhhN3w26lpQb6dspetweapMn2CSNwQ8I4wg==",
"dev": true,
"license": "MIT",
"optional": true,
"dependencies": {
@@ -847,7 +846,6 @@
"version": "1.7.1",
"resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.7.1.tgz",
"integrity": "sha512-PVtJr5CmLwYAU9PZDMITZoR5iAOShYREoR45EyyLrbntV50mdePTgUn4AmOw90Ifcj+x2kRjdzr1HP3RrNiHGA==",
"dev": true,
"license": "MIT",
"optional": true,
"dependencies": {
@@ -858,7 +856,6 @@
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.1.0.tgz",
"integrity": "sha512-WI0DdZ8xFSbgMjR1sFsKABJ/C5OnRrjT06JXbZKexJGrDuPTzZdDYfFlsgcCXCyf+suG5QU2e/y1Wo2V/OapLQ==",
"dev": true,
"license": "MIT",
"optional": true,
"dependencies": {
@@ -1348,7 +1345,6 @@
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.0.tgz",
"integrity": "sha512-Fq6DJW+Bb5jaWE69/qOE0D1TUN9+6uWhCeZpdnSBk14pjLcCWR7Q8n49PTSPHazM37JqrsdpEthXy2xn6jWWiA==",
"dev": true,
"license": "MIT",
"optional": true,
"dependencies": {
@@ -1503,7 +1499,6 @@
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1520,7 +1515,6 @@
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1537,7 +1531,6 @@
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1554,7 +1547,6 @@
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1571,7 +1563,6 @@
"cpu": [
"arm"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1588,7 +1579,6 @@
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1605,7 +1595,6 @@
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1622,7 +1611,6 @@
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1639,7 +1627,6 @@
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1656,7 +1643,6 @@
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1673,7 +1659,6 @@
"cpu": [
"wasm32"
],
"dev": true,
"license": "MIT",
"optional": true,
"dependencies": {
@@ -1690,7 +1675,6 @@
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1707,7 +1691,6 @@
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -2313,7 +2296,6 @@
"version": "0.10.1",
"resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.1.tgz",
"integrity": "sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg==",
"dev": true,
"license": "MIT",
"optional": true,
"dependencies": {
@@ -7193,7 +7175,7 @@
"version": "1.21.7",
"resolved": "https://registry.npmjs.org/jiti/-/jiti-1.21.7.tgz",
"integrity": "sha512-/imKNG4EbWNrVjoNC/1H5/9GFy+tqjGBHCaSsN+P2RnPqjsLmv6UD3Ej+Kj8nBWaRAwyk7kK5ZUc+OEatnTR3A==",
"dev": true,
"devOptional": true,
"license": "MIT",
"bin": {
"jiti": "bin/jiti.js"
@@ -7692,7 +7674,6 @@
"cpu": [
"arm64"
],
"dev": true,
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -7713,7 +7694,6 @@
"cpu": [
"arm64"
],
"dev": true,
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -7734,7 +7714,6 @@
"cpu": [
"x64"
],
"dev": true,
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -7755,7 +7734,6 @@
"cpu": [
"x64"
],
"dev": true,
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -7776,7 +7754,6 @@
"cpu": [
"arm"
],
"dev": true,
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -7797,7 +7774,6 @@
"cpu": [
"arm64"
],
"dev": true,
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -7818,7 +7794,6 @@
"cpu": [
"arm64"
],
"dev": true,
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -7839,7 +7814,6 @@
"cpu": [
"x64"
],
"dev": true,
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -7860,7 +7834,6 @@
"cpu": [
"x64"
],
"dev": true,
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -7881,7 +7854,6 @@
"cpu": [
"arm64"
],
"dev": true,
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -7902,7 +7874,6 @@
"cpu": [
"x64"
],
"dev": true,
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -12529,21 +12500,6 @@
}
}
},
"node_modules/svelte-check/node_modules/picomatch": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz",
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true,
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/jonschlinkert"
}
},
"node_modules/svelte-eslint-parser": {
"version": "0.43.0",
"resolved": "https://registry.npmjs.org/svelte-eslint-parser/-/svelte-eslint-parser-0.43.0.tgz",