Repository navigation
Abort broken connections instead of closing them - #530
Merged
Dreamsorcerer merged 3 commits intoNov 24, 2026
Merged
Conversation
A command that times out or is cancelled can leave part of itself in the transport's write buffer. release(broken=True) closed the writer, which sends that buffer before closing, so memcached could still carry out a set() after the caller got TimeoutError, and the socket outlived its pool slot until the flush finished. Abort the transport instead so the buffered data is dropped. clear() still closes idle connections gracefully.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #530 +/- ##
==========================================
+ Coverage 97.97% 98.37% +0.39%
==========================================
Files 10 10
Lines 1037 1229 +192
Branches 57 65 +8
==========================================
+ Hits 1016 1209 +193
Misses 12 12
+ Partials 9 8 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
[Medium impact] The PR appears safe to merge. Reviews (3) · Last reviewed commit: "Update aiomcache/pool.py" · Reviewed by Greptile |
Otherwise the deadline could expire before set() wrote anything, and the test would pass even with a graceful close.
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.
When a command times out or is cancelled, part of it can still be in the transport's write buffer.
release(broken=True)calledwriter.close(), which sends that buffer before closing. memcached could then carry out aset()after the caller had already gotTimeoutError, and the socket stayed open beyond its pool slot until the flush finished. With thetimeoutoption, any slow write that times out can hit this.Close broken connections with
transport.abort()instead, which drops the buffer.clear()still closes idle connections gracefully. The new test times out a 16 MBset()against a server that isn't reading yet, then checks that the server doesn't receive the whole value. On master the server receives all of it.