Use get_result instead of execute for pool connection ping#294
Merged
weiznich merged 1 commit intoJun 19, 2026
Merged
Conversation
The Verified recycling method now reads the result row from SELECT 1 via get_result::<i32>() instead of discarding it with execute(). This detects connections with corrupt read buffers that would otherwise pass the ping check but fail on subsequent queries. Fixes diesel-rs#139
weiznich
force-pushed
the
fix/pool-ping-read-response
branch
from
June 19, 2026 06:58
844ab4f to
66a6877
Compare
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.
Summary
Verifiedrecycling method's ping from.execute()to.get_result::<i32>()so the response row is actually read back from the server.execute()(which only reads the row count) but fail on real queries with "Unexpected end of row" / "buf doesn't have enough data" errorsExecuteDsltoLoadQueryacross all pool backends (bb8, deadpool, mobc) and the r2d2 connection wrapperFixes #139
Context
As discussed in #139, the current ping uses
.execute("SELECT 1")which sends the query and reads the affected row count, but never reads actual row data. A connection whose read buffer contains leftover bytes from a previous partially-consumed response will pass this check, get returned to the pool, and then fail on the next real query.Using
.get_result::<i32>()forces the connection to deserialize a row, which will surface buffer corruption immediately during the health check rather than on a subsequent application query.Test plan
cargo check --features "postgres bb8 deadpool mobc r2d2"— compiles cleanlycargo check --features "mysql bb8 deadpool mobc"— compiles cleanlycargo check --features "sqlite bb8 deadpool mobc r2d2"— compiles cleanly