Skip to content

feat(core): expose acquired pool connections#4279

Open
angelnereira wants to merge 2 commits into
launchbadge:mainfrom
angelnereira:feat/pool-num-acquired
Open

feat(core): expose acquired pool connections#4279
angelnereira wants to merge 2 commits into
launchbadge:mainfrom
angelnereira:feat/pool-num-acquired

Conversation

@angelnereira
Copy link
Copy Markdown

@angelnereira angelnereira commented May 25, 2026

Summary

  • add Pool::num_acquired() to report checked-out pool connections
  • include num_acquired in Pool debug output
  • add coverage for the new counter through the Any pool tests
  • close SQLCipher test connections explicitly so the SQLite matrix does not rely on process-exit teardown

This helps applications distinguish a full-but-idle pool from one where all connections are checked out, which is useful when diagnosing pool contention and PoolTimedOut errors.

The SQLCipher change is test-only. The SQLite matrix was reporting all sqlite-sqlcipher tests as passed and then segfaulting at process exit; closing the test connections explicitly makes the teardown deterministic.

Checks

  • cargo fmt
  • cargo check -p sqlx-core --no-default-features --features any,_rt-tokio
  • cargo clippy -p sqlx-core --no-default-features --features any,_rt-tokio -- -D warnings
  • cargo test --no-run --test any-pool --no-default-features --features any,sqlite,macros,runtime-tokio
  • DATABASE_URL=sqlite::memory: cargo test --test any-pool pool_should_report_acquired_connections --no-default-features --features any,sqlite,macros,runtime-tokio
  • RUSTFLAGS='--cfg sqlite_test_sqlcipher' DATABASE_URL=sqlite:tests/sqlite/sqlite.db cargo test --test sqlite-sqlcipher --no-default-features --features any,macros,migrate,sqlite,_unstable-all-types,runtime-tokio -- --test-threads=1
  • RUSTFLAGS='--cfg sqlite_test_sqlcipher' DATABASE_URL=sqlite:tests/sqlite/sqlite.db cargo test --test sqlite-sqlcipher --no-default-features --features any,macros,migrate,sqlite,_unstable-all-types,runtime-smol -- --test-threads=1
  • RUSTFLAGS='--cfg sqlite_test_sqlcipher' DATABASE_URL=sqlite:tests/sqlite/sqlite.db cargo test --no-default-features --features any,macros,migrate,sqlite,_unstable-all-types,runtime-tokio,sqlite-preupdate-hook -- --skip rustsec_2024_0363 --test-threads=1
  • cargo test -p sqlx --doc --no-default-features --features any,postgres,macros,runtime-tokio
  • git diff --check

Note: cargo clippy --test any-pool --no-default-features --features any,sqlite,macros,runtime-tokio -- -D warnings currently reports an existing clippy::needless_question_mark warning in sqlx-test/src/lib.rs, outside this change.

@angelnereira angelnereira force-pushed the feat/pool-num-acquired branch from 6d7ab7e to 4563689 Compare May 25, 2026 03:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant