Compare commits

...

4 Commits

Author SHA1 Message Date
Alexander Petric
387a0c854d fix: pipeline RESET ALL with first query via tokio::join
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-03 20:41:48 +00:00
Alexander Petric
43d2cf4522 fix: move RESET ALL inside result_f async block
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-03 20:33:13 +00:00
Alexander Petric
3f55f226c3 Merge branch 'main' into alp/postgres_state_reset 2026-04-03 16:02:37 -04:00
Alexander Petric
1904ffcaaa fix: reset postgres session state on cached connection reuse
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-03 20:00:21 +00:00

View File

@@ -399,7 +399,7 @@ pub async fn do_postgresql(
continue;
}
let result = do_postgresql_inner(
let inner_fut = do_postgresql_inner(
query.to_string(),
&param_idx_to_arg_and_value,
client,
@@ -418,8 +418,23 @@ pub async fn do_postgresql(
collection_strategy.collect_first_row_only(),
s3.clone(),
typed_schema,
)?
.await?;
)?;
// For cached connections, pipeline RESET ALL with the first query using
// tokio::join! so both messages are sent on the wire before either response
// is read — zero additional round-trip latency. This resets session state
// (role, search_path, statement_timeout, etc.) to prevent leaking between
// unrelated script executions sharing this cached connection.
let result = if i == 0 && has_cached_con {
let (reset_result, query_result) =
tokio::join!(client.simple_query("RESET ALL"), inner_fut);
if let Err(e) = reset_result {
tracing::warn!("Failed to RESET ALL on cached pg connection: {e}");
}
query_result?
} else {
inner_fut.await?
};
results.push(result);
}