Repository navigation
fix(sdk): keep an explicit disconnect until the next connect - #4388
TomPlanche wants to merge 1 commit into
Conversation
|
Thanks for the PR. It is labeled Slash commands (own line, regular comment) move it around the queue:
See CONTRIBUTING.md for details. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #4388 +/- ##
============================================
- Coverage 88.45% 87.88% -0.57%
Complexity 1607 1607
============================================
Files 1302 1302
Lines 252659 252861 +202
Branches 212824 213025 +201
============================================
- Hits 223498 222236 -1262
- Misses 23791 25272 +1481
+ Partials 5370 5353 -17
🚀 New features to boost your workflow:
|
|
/request-review @jiengup |
|
/request-review @hubcio |
|
Thanks @numinnex for the great review. I checked each point against the code, and these five hold:
The doc and test nits are valid too. So a flag checked at the entry points is not enough: it must be checked at every step of the reconnect sweep, on all three transports. That is the same code #4345 changes, and close to problems 5 to 8 of #4287 and to #3651. I asked on #4287 how you want it scoped before I change more of the state machine. |
|
/ready |
|
/request-review @numinnex |
|
@TomPlanche could you please rebase this? |
78939bf to
9d1521a
Compare
Which issue does this PR address?
Relates to #4287
Rationale
An explicit
disconnect()must hold until the nextconnect(), as agreed on #4287: the test indisconnect_relogin.rsis the correct contract, not theIggyClientdocs. Problems 2 and 3 of #4287 break this rule for a client with auto-login credentials. This PR fixes these two problems.What changed?
After
disconnect(), a client with auto-login credentials came back on its own. The heartbeat kept running and its ping reconnected the client and signed in again, and a directping()orget_stats()did the same. Only an authenticated request such asget_me()failed, becausefail_if_not_authenticatedrejects it before the transport.Now the
Clienttrait impl ofdisconnect()sets a caller-intent flag on TCP, QUIC and WebSocket, and the trait impl ofconnect()clears it. While the flag is set,send_raw_with_responsefails withNotConnectedat once: no packets on the wire, no wait, no reconnect. The flag lives only in the trait impl, because leader redirection and the reconnect path call the inherentdisconnect(). A connection that drops withoutdisconnect()leaves the flag clear, so that loss still heals.IggyClient::disconnectalso stops the heartbeat, andconnectstarts it again. This removes the useless pings, and on QUIC it removes the redial that blockeddisconnect()inendpoint.wait_idle().The
Clienttrait now documents thedisconnect()contract. TheIggyClient, Python and C++ docs no longer say that auto-login undoes a disconnect. The last two lifecycle tests from #4344 lose their#[ignore], so all 10 cases ofclient_lifecycle.rsnow run.Local Execution
I used Zed in devcontainer mode. The build and the tests ran in the devcontainer, and
prekran on macOS.Passed:
cargo fmt --allandcargo clippy -p iggy_common -p iggy -p integration --all-features --all-targets -- -D warnings.Passed:
cargo test -p iggy --lib, with 234 tests.Passed: the lifecycle tests, with all 10 cases and none ignored, in 3 runs out of 3:
Passed: the
sdk::integration suite (69 passed, 0 ignored), which includesdisconnect_relogin.rs, and thecluster::suite (80 passed), because the flag sits in the reconnect path that failovers use.Passed: the Python lifecycle tests against a local server:
Passed:
cargo run --bin stub_gen. The stub diff contains only thedisconnect()docstring.Passed: pre-commit hooks with
SKIP=web-lint prek run --all-files. I skippedweb-lintbecause this PR does not changeweb/.AI Usage