perf: opt into sqlx test templates through SQLX_TEST_TEMPLATE (#11853)

* perf: opt into sqlx test templates through SQLX_TEST_TEMPLATE

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

* fix: raise the sqlx test connection cap so concurrent tests cannot starve

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ruben Fiszel
2026-10-17 23:23:53 +02:00
committed by GitHub
co-authored by Claude Opus 5.5
parent db3814f8f9
commit 7a2d913458
3 changed files with 23 additions and 20 deletions
+4 -1
View File
@@ -27,8 +27,11 @@ rustflags = [
git-fetch-with-cli = true
[env]
# `#[sqlx::test]` clones each test database from a template migrated once, instead of running
# every migration per test. The `_sqlx_tmpl_*` databases it leaves on the server are reused.
SQLX_TEST_TEMPLATE = "true"
# 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"
SQLX_TEST_MAX_CONNECTIONS = "50"
+7 -7
View File
@@ -12610,7 +12610,7 @@ dependencies = [
[[package]]
name = "sqlx"
version = "0.8.6"
source = "git+https://github.com/windmill-labs/sqlx?rev=cb0d1c3d481f993b763806c0d96e63e53b870a70#cb0d1c3d481f993b763806c0d96e63e53b870a70"
source = "git+https://github.com/windmill-labs/sqlx?rev=c1c5f1f2a07cb1fce0e47463c314697e08f4f26b#c1c5f1f2a07cb1fce0e47463c314697e08f4f26b"
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=cb0d1c3d481f993b763806c0d96e63e53b870a70#cb0d1c3d481f993b763806c0d96e63e53b870a70"
source = "git+https://github.com/windmill-labs/sqlx?rev=c1c5f1f2a07cb1fce0e47463c314697e08f4f26b#c1c5f1f2a07cb1fce0e47463c314697e08f4f26b"
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=cb0d1c3d481f993b763806c0d96e63e53b870a70#cb0d1c3d481f993b763806c0d96e63e53b870a70"
source = "git+https://github.com/windmill-labs/sqlx?rev=c1c5f1f2a07cb1fce0e47463c314697e08f4f26b#c1c5f1f2a07cb1fce0e47463c314697e08f4f26b"
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=cb0d1c3d481f993b763806c0d96e63e53b870a70#cb0d1c3d481f993b763806c0d96e63e53b870a70"
source = "git+https://github.com/windmill-labs/sqlx?rev=c1c5f1f2a07cb1fce0e47463c314697e08f4f26b#c1c5f1f2a07cb1fce0e47463c314697e08f4f26b"
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=cb0d1c3d481f993b763806c0d96e63e53b870a70#cb0d1c3d481f993b763806c0d96e63e53b870a70"
source = "git+https://github.com/windmill-labs/sqlx?rev=c1c5f1f2a07cb1fce0e47463c314697e08f4f26b#c1c5f1f2a07cb1fce0e47463c314697e08f4f26b"
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=cb0d1c3d481f993b763806c0d96e63e53b870a70#cb0d1c3d481f993b763806c0d96e63e53b870a70"
source = "git+https://github.com/windmill-labs/sqlx?rev=c1c5f1f2a07cb1fce0e47463c314697e08f4f26b#c1c5f1f2a07cb1fce0e47463c314697e08f4f26b"
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=cb0d1c3d481f993b763806c0d96e63e53b870a70#cb0d1c3d481f993b763806c0d96e63e53b870a70"
source = "git+https://github.com/windmill-labs/sqlx?rev=c1c5f1f2a07cb1fce0e47463c314697e08f4f26b#c1c5f1f2a07cb1fce0e47463c314697e08f4f26b"
dependencies = [
"atoi",
"chrono",
+12 -12
View File
@@ -226,11 +226,11 @@ all_sqlx_features = ["all_languages", "enterprise", "enterprise_saml", "embeddin
"windmill-git-sync/all_sqlx_features"]
[patch.crates-io]
# 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.
# v0.8.6 plus the fix below and two `#[sqlx::test]`-only changes, both set in .cargo/config.toml:
# `SQLX_TEST_TEMPLATE` clones each test database from a template migrated once per migration
# set instead of migrating it per test, and `SQLX_TEST_MAX_CONNECTIONS` lifts the cap on the
# connections all test pools share. The rev is tagged `windmill-0.8.6-test-template-c1c5f1f` 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
@@ -244,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 = "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" }
sqlx = { git = "https://github.com/windmill-labs/sqlx", rev = "c1c5f1f2a07cb1fce0e47463c314697e08f4f26b" }
sqlx-core = { git = "https://github.com/windmill-labs/sqlx", rev = "c1c5f1f2a07cb1fce0e47463c314697e08f4f26b" }
sqlx-macros = { git = "https://github.com/windmill-labs/sqlx", rev = "c1c5f1f2a07cb1fce0e47463c314697e08f4f26b" }
sqlx-macros-core = { git = "https://github.com/windmill-labs/sqlx", rev = "c1c5f1f2a07cb1fce0e47463c314697e08f4f26b" }
sqlx-postgres = { git = "https://github.com/windmill-labs/sqlx", rev = "c1c5f1f2a07cb1fce0e47463c314697e08f4f26b" }
sqlx-mysql = { git = "https://github.com/windmill-labs/sqlx", rev = "c1c5f1f2a07cb1fce0e47463c314697e08f4f26b" }
sqlx-sqlite = { git = "https://github.com/windmill-labs/sqlx", rev = "c1c5f1f2a07cb1fce0e47463c314697e08f4f26b" }
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" }