From 03b540979ab4431df87560535cc63f23df1384fd Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Sat, 17 Oct 2026 22:58:56 +0200 Subject: [PATCH] test: lift the shared sqlx test pool cap so concurrent tests cannot starve (#11855) Co-authored-by: Claude Opus 5.5 --- backend/.cargo/config.toml | 9 ++++++++- backend/Cargo.lock | 14 +++++++------- backend/Cargo.toml | 22 ++++++++++++---------- 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/backend/.cargo/config.toml b/backend/.cargo/config.toml index f8b0a5e32a..9284b39837 100644 --- a/backend/.cargo/config.toml +++ b/backend/.cargo/config.toml @@ -24,4 +24,11 @@ rustflags = [ ] [net] -git-fetch-with-cli = true \ No newline at end of file +git-fetch-with-cli = true + +[env] +# All `#[sqlx::test]` pools of a test binary share this many connections, and each keeps the +# ones it took until it ends: below 5 per test thread, concurrent tests can split them all and +# wait on each other until their acquire times out. 50 covers CI's `--test-threads=10`; a run +# with more threads over a binary of more than 10 tests needs 5 per thread. +SQLX_TEST_MAX_CONNECTIONS = "50" \ No newline at end of file diff --git a/backend/Cargo.lock b/backend/Cargo.lock index 4762c7f47d..e442dbc533 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -12610,7 +12610,7 @@ dependencies = [ [[package]] name = "sqlx" version = "0.8.6" -source = "git+https://github.com/windmill-labs/sqlx?rev=bc69ecc388ded2a5d770a83bf54803af24706057#bc69ecc388ded2a5d770a83bf54803af24706057" +source = "git+https://github.com/windmill-labs/sqlx?rev=cb0d1c3d481f993b763806c0d96e63e53b870a70#cb0d1c3d481f993b763806c0d96e63e53b870a70" dependencies = [ "sqlx-core", "sqlx-macros", @@ -12622,7 +12622,7 @@ dependencies = [ [[package]] name = "sqlx-core" version = "0.8.6" -source = "git+https://github.com/windmill-labs/sqlx?rev=bc69ecc388ded2a5d770a83bf54803af24706057#bc69ecc388ded2a5d770a83bf54803af24706057" +source = "git+https://github.com/windmill-labs/sqlx?rev=cb0d1c3d481f993b763806c0d96e63e53b870a70#cb0d1c3d481f993b763806c0d96e63e53b870a70" dependencies = [ "base64 0.22.1", "bigdecimal", @@ -12660,7 +12660,7 @@ dependencies = [ [[package]] name = "sqlx-macros" version = "0.8.6" -source = "git+https://github.com/windmill-labs/sqlx?rev=bc69ecc388ded2a5d770a83bf54803af24706057#bc69ecc388ded2a5d770a83bf54803af24706057" +source = "git+https://github.com/windmill-labs/sqlx?rev=cb0d1c3d481f993b763806c0d96e63e53b870a70#cb0d1c3d481f993b763806c0d96e63e53b870a70" dependencies = [ "proc-macro2", "quote", @@ -12672,7 +12672,7 @@ dependencies = [ [[package]] name = "sqlx-macros-core" version = "0.8.6" -source = "git+https://github.com/windmill-labs/sqlx?rev=bc69ecc388ded2a5d770a83bf54803af24706057#bc69ecc388ded2a5d770a83bf54803af24706057" +source = "git+https://github.com/windmill-labs/sqlx?rev=cb0d1c3d481f993b763806c0d96e63e53b870a70#cb0d1c3d481f993b763806c0d96e63e53b870a70" dependencies = [ "dotenvy", "either", @@ -12696,7 +12696,7 @@ dependencies = [ [[package]] name = "sqlx-mysql" version = "0.8.6" -source = "git+https://github.com/windmill-labs/sqlx?rev=bc69ecc388ded2a5d770a83bf54803af24706057#bc69ecc388ded2a5d770a83bf54803af24706057" +source = "git+https://github.com/windmill-labs/sqlx?rev=cb0d1c3d481f993b763806c0d96e63e53b870a70#cb0d1c3d481f993b763806c0d96e63e53b870a70" dependencies = [ "atoi", "base64 0.22.1", @@ -12740,7 +12740,7 @@ dependencies = [ [[package]] name = "sqlx-postgres" version = "0.8.6" -source = "git+https://github.com/windmill-labs/sqlx?rev=bc69ecc388ded2a5d770a83bf54803af24706057#bc69ecc388ded2a5d770a83bf54803af24706057" +source = "git+https://github.com/windmill-labs/sqlx?rev=cb0d1c3d481f993b763806c0d96e63e53b870a70#cb0d1c3d481f993b763806c0d96e63e53b870a70" dependencies = [ "atoi", "base64 0.22.1", @@ -12780,7 +12780,7 @@ dependencies = [ [[package]] name = "sqlx-sqlite" version = "0.8.6" -source = "git+https://github.com/windmill-labs/sqlx?rev=bc69ecc388ded2a5d770a83bf54803af24706057#bc69ecc388ded2a5d770a83bf54803af24706057" +source = "git+https://github.com/windmill-labs/sqlx?rev=cb0d1c3d481f993b763806c0d96e63e53b870a70#cb0d1c3d481f993b763806c0d96e63e53b870a70" dependencies = [ "atoi", "chrono", diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 88f59124b2..48fa9c2460 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -226,9 +226,11 @@ all_sqlx_features = ["all_languages", "enterprise", "enterprise_saml", "embeddin "windmill-git-sync/all_sqlx_features"] [patch.crates-io] -# v0.8.6 plus two changes, the fix below and a `#[sqlx::test]`-only one: each test database is -# cloned from a template migrated once per migration set instead of migrating it per test. -# The rev is tagged `windmill-0.8.6-test-template-bc69ecc` in the fork so it stays fetchable. +# v0.8.6 plus the fix below and two `#[sqlx::test]`-only changes: each test database is +# cloned from a template migrated once per migration set instead of migrating it per test, and +# `SQLX_TEST_MAX_CONNECTIONS` (set in .cargo/config.toml) lifts the cap on the connections all +# test pools share. The rev is tagged `windmill-0.8.6-test-pool-cap-cb0d1c3` in the fork so it +# stays fetchable. # The fix: `Pool::begin` is not cancel-safe on Postgres. sqlx raises the # transaction depth its rollback-on-drop guard keys on only *after* the BEGIN round trip, so # a cancelled caller (a disconnecting API client, a `timeout`, an aborted task) leaves the @@ -242,13 +244,13 @@ all_sqlx_features = ["all_languages", "enterprise", "enterprise_saml", "embeddin # Changing any of this — a bump, a rebase of the fork, dropping these lines — still compiles # clean, so run the guard that actually checks the behaviour is still there: # cargo test -p windmill-common --test sqlx_begin_cancel_safe -- --ignored -sqlx = { git = "https://github.com/windmill-labs/sqlx", rev = "bc69ecc388ded2a5d770a83bf54803af24706057" } -sqlx-core = { git = "https://github.com/windmill-labs/sqlx", rev = "bc69ecc388ded2a5d770a83bf54803af24706057" } -sqlx-macros = { git = "https://github.com/windmill-labs/sqlx", rev = "bc69ecc388ded2a5d770a83bf54803af24706057" } -sqlx-macros-core = { git = "https://github.com/windmill-labs/sqlx", rev = "bc69ecc388ded2a5d770a83bf54803af24706057" } -sqlx-postgres = { git = "https://github.com/windmill-labs/sqlx", rev = "bc69ecc388ded2a5d770a83bf54803af24706057" } -sqlx-mysql = { git = "https://github.com/windmill-labs/sqlx", rev = "bc69ecc388ded2a5d770a83bf54803af24706057" } -sqlx-sqlite = { git = "https://github.com/windmill-labs/sqlx", rev = "bc69ecc388ded2a5d770a83bf54803af24706057" } +sqlx = { git = "https://github.com/windmill-labs/sqlx", rev = "cb0d1c3d481f993b763806c0d96e63e53b870a70" } +sqlx-core = { git = "https://github.com/windmill-labs/sqlx", rev = "cb0d1c3d481f993b763806c0d96e63e53b870a70" } +sqlx-macros = { git = "https://github.com/windmill-labs/sqlx", rev = "cb0d1c3d481f993b763806c0d96e63e53b870a70" } +sqlx-macros-core = { git = "https://github.com/windmill-labs/sqlx", rev = "cb0d1c3d481f993b763806c0d96e63e53b870a70" } +sqlx-postgres = { git = "https://github.com/windmill-labs/sqlx", rev = "cb0d1c3d481f993b763806c0d96e63e53b870a70" } +sqlx-mysql = { git = "https://github.com/windmill-labs/sqlx", rev = "cb0d1c3d481f993b763806c0d96e63e53b870a70" } +sqlx-sqlite = { git = "https://github.com/windmill-labs/sqlx", rev = "cb0d1c3d481f993b763806c0d96e63e53b870a70" } object_store = { git = "https://github.com/apache/arrow-rs-object-store", rev = "36752c975d4f29e20b57c91f81a10872dcd48ae7" } # Use tiberius main branch for libgssapi 0.8.1 fix (https://github.com/prisma/tiberius/issues/343) tiberius = { git = "https://github.com/prisma/tiberius", rev = "59db57960a14b422fb3a1309aa4aa47880896ff8" }