refactor(pool): use asyncband for all semaphore backends - #4404
Open
tisonkun wants to merge 1 commit into
Open
Conversation
tisonkun
marked this pull request as ready for review
September 8, 2026 08:28
Contributor
Author
|
Background: This Semaphore is always fair and does not integrate with tokio-console's traces. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Does your PR solve an issue?
Partially addresses #1668 by removing
futures-intrusivefromsqlx-core.sqlx-sqlitestill uses its mutex, so this does not close that issue.Use
asyncband0.7.1's fair semaphore for every runtime, replacing both the Tokio and futures-intrusive implementations ofAsyncSemaphore. Keep the pool's existing permit ownership, manual release, and close-event protocol while removing the runtime-specific adapter branches and the non-fair benchmarking option.Is this a breaking change?
No change to the supported SQLx API or its FIFO pool-acquisition contract. There are implementation-level changes to review:
PoolOptions::__fairmethod and thefairargument ofsqlx-core::sync::AsyncSemaphore::new. Thesqlx-coreAPI is explicitly SemVer-exempt.tokio-consoleor participate in Tokio's cooperative polling budget through the semaphore.Validation
Added deterministic pool tests for FIFO acquisition after waiter cancellation, closing while connections remain checked out (including cancellation of a partially satisfied multi-permit acquisition), and returning child-pool permits to the parent.
any-pooltests on Tokio, smol, async-global-executor, and async-std: 6 passed and 1 existing ignored test for each runtime.sqliteintegration tests on Tokio and smol: 44 passed and 1 existing ignored test for each runtime.cargo test -p sqlx-core --all-features: 7 unit tests and 30 doc tests passed; 31 doc tests ignored.cargo clippy -p sqlx-core --all-targets --all-features -- -D warningscargo check -p sqlx-core --no-default-featurescargo fmt --all -- --checkAn additional Clippy check of the
any-pooltest target encounters an existingneedless_question_markwarning in unchangedsqlx-test/src/lib.rs:20. It passes with only that lint allowed (-D warnings -A clippy::needless_question_mark).AI assisted with the implementation, tests, and PR draft.