Repository navigation
Discard connections whose validation was interrupted - #325
chenty2333 wants to merge 1 commit into
Conversation
If get() is dropped while is_valid is pending, the connection was returned to the pool as Present, possibly with the validation exchange half done. Keep it Invalid until validation succeeds so that dropping discards it. Fixes djc#324.
djc/bb8#324 (issue), djc/bb8#325 (fix with a regression test) and dqminh/bb8-memcached#16.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #325 +/- ##
==========================================
+ Coverage 77.99% 78.06% +0.06%
==========================================
Files 6 6
Lines 659 661 +2
==========================================
+ Hits 514 516 +2
Misses 145 145 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Additional real-client validation for this fix: I applied the invalid-until-validation-completes change from this PR to a separate 0.8.6 copy, without upgrading the driver or adapter. In three checkout-only rounds, all six original cancellation attempts caused a subsequent-use failure; all six patched attempts completed the subsequent write correctly. All cancellation points were reached. The connection counters distinguish the mechanism: original code has one idle connection immediately after cancellation and replaces it only after the later error. With the patch it has zero connections immediately after cancellation, then creates a new one for the next borrower. Uncancelled reuse and an explicit This adds another concrete affected adapter, rather than a new report of the same bb8 issue. Reproduction, patch copy and results. |
Fixes #324.
If
get()is dropped whileManageConnection::is_validis pending (by the caller, or by the pool's ownconnection_timeout), the connection was returned to the pool asPresent, possibly with the validation exchange half done. This marks the connectionInvalidbefore awaitingis_validand sets it back toPresenton success, so dropping discards the connection and the pool replenishes as it does after a failed validation.test_drop_during_is_validmodels a request/response connection whose validation stalls once. It fails onmain, where the nextget()returns the connection with its validation request still unanswered, and passes with this change. The rest of the test suite passes on stable and 1.75;cargo fmtandcargo clippy --all-targetsare clean.