From 1904ffcaaabc37742b7a64fdbdab485287803fbd Mon Sep 17 00:00:00 2001 From: Alexander Petric Date: Fri, 3 Apr 2026 20:00:21 +0000 Subject: [PATCH] fix: reset postgres session state on cached connection reuse Co-Authored-By: Claude Opus 4.5 --- backend/windmill-worker/src/pg_executor.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backend/windmill-worker/src/pg_executor.rs b/backend/windmill-worker/src/pg_executor.rs index ba89a55f97..2f678bc6e1 100644 --- a/backend/windmill-worker/src/pg_executor.rs +++ b/backend/windmill-worker/src/pg_executor.rs @@ -357,6 +357,11 @@ pub async fn do_postgresql( (client, Some(handle)) } else { let (_, client) = mtex.as_ref().unwrap().as_ref().unwrap(); + // Reset all session state (role, search_path, statement_timeout, etc.) to defaults + // to prevent state leaking between unrelated script executions sharing this cached connection. + if let Err(e) = client.simple_query("RESET ALL").await { + tracing::warn!("Failed to RESET ALL on cached connection: {}", e); + } (client, None) };