fix: use transaction for parallel_monitor_lock DELETE in last-iteration path (#9789)

In the last-iteration path of a parallel for-loop (nindex == len), the
DELETE FROM parallel_monitor_lock ran on the pool (db) while the
transaction tx (begun earlier) was still held. This dual-connection
pattern requires 2 simultaneous connections from the per-worker pool
(default max 5) and can trigger "pool timed out while waiting for an
open connection" under concurrent load.

Run the DELETE on the held transaction (&mut *tx) instead, matching the
fix PR #7861 applied to other queries in this file. The transaction is
committed shortly after, so including the DELETE in it is safe and
consistent with the non-last-iteration path.

Fixes WIN-2099

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ruben Fiszel
2026-06-25 15:34:05 +02:00
committed by GitHub
parent 12f92e3ab7
commit 754cae956a
+1 -1
View File
@@ -1054,7 +1054,7 @@ pub async fn update_flow_status_after_job_completion_internal(
let r = sqlx::query_scalar!(
"DELETE FROM parallel_monitor_lock WHERE parent_flow_id = $1 RETURNING last_ping",
flow,
).fetch_optional(db).await.map_err(|e| {
).fetch_optional(&mut *tx).await.map_err(|e| {
Error::internal_err(format!(
"error while deleting parallel_monitor_lock: {e:#}"
))