Repository navigation
Bound large database writes and shutdowns on non-reading peers - #1387
Merged
Merged
Conversation
Member
Author
|
Independent review: PASS at head 1640353
|
|
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.



Fixes #1385.
What changes
sqlx-mysql(rust/vendor/sqlx-mysql/src/connection/stream.rs):MySqlStream::flushandMySqlStream::shutdownshadowingBufferedSocket::{flush,shutdown}, bounding every socket flush and close by the connection'sreply_deadline/reply_timeout(45 s for statements, 5 s for release).flush_queuedandwait_until_readythroughself.flush().await?instead of bypassing toself.socket.flush().reply_failed = trueand returnError::Io(ErrorKind::TimedOut)so subsequent reads, flushes, andclose_hard()shutdowns fail immediately and discard the connection instead of hanging on unflushed buffer bytes.sqlx-postgres(rust/vendor/sqlx-postgres/src/connection/stream.rs):PgStream::flushandPgStream::shutdownwith the exact samereply_deadline/reply_timeoutbound andreply_faileddiscard behavior.test_reply_gate.rs,mysql_stall_tests.rs,postgres.rs):ReplyGate::hold_upstreamso the proxy stops callingread()on the client socket.qualification_a_large_write_to_a_non_reading_peer_fails_within_its_boundfor both MySQL/MariaDB and PostgreSQL: sends a 24 MiB parameter after preparing the statement, verifiesErrorKind::TimedOutfrom the write flush within the shortened bound, verifiesreturn_to_pool()discards the connection in< 1 s, and verifies the nextacquire()opens a fresh session.docs/server-reference.md,rust/vendor/sqlx-mysql/DURABLE-PATCH.md, andrust/vendor/sqlx-postgres/DURABLE-PATCH.md.Verification
runtime::mysql::stall_tests::qualification_a_{statement_in_flight_on_a_silent_peer_fails_within_its_reply_bound,release_on_a_silent_peer_ends_within_its_reply_bound,large_write_to_a_non_reading_peer_fails_within_its_bound}— 3 passed, 0 failed (3.06 s).runtime::postgres::tests::qualification_a_{statement_in_flight_on_a_silent_peer_fails_within_its_reply_bound,release_on_a_silent_peer_ends_within_its_reply_bound,large_write_to_a_non_reading_peer_fails_within_its_bound}— 3 passed, 0 failed (3.41 s).