Repository navigation
Conversation
A graceful shutdown sends a Logout, which is persisted like every outbound
message. When the store refuses it (for example a store that has been fenced
because another process took the session over), the error was returned
before the state changed: the session stayed connected and the connection
loop kept dialling and failing to log on.
Now a Logout that cannot be persisted is not sent; the connection is closed
and the session moves to Disconnected with the requested reconnect flag.
A shutdown without reconnect requested while the session is between
reconnect attempts also moves it to Disconnected { reconnect: false },
instead of being ignored, so the connection loop ends.
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.
Problem
A graceful shutdown sends a Logout, and the Logout is persisted like every outbound message. If the store refuses the write,
initiate_graceful_logoutreturns the error before the state changes. The session stays connected,Initiator::shutdowndoes not complete, and the connection loop keeps going.This matters for stores that deliberately refuse writes. One example is a store fenced to a single writer, so that when another process takes over a session, the old process can no longer write to it. Shutting the old process down is exactly when its writes are refused.
Separately,
shutdown(false)while the session is disconnected between reconnect attempts was ignored: there is no connection to log out of, so the request did nothing and the connection loop dialled again.Change
In
SessionState::initiate_graceful_logout:Disconnectedwith the requestedreconnectflag. The error is logged as a warning.Disconnected { reconnect: false }, so the connection loop ends. A request with reconnect while disconnected is unchanged.The normal path (Logout persisted and sent, then AwaitingLogout) is unchanged.
Tests
Unit tests in
session.rs, using the existingTestStorewith a newfail_addswitch:test_shutdown_disconnects_when_logout_cannot_be_persisted: nothing is written except a disconnect, and the session ends disconnected without reconnect.test_end_of_session_logout_failure_keeps_reconnect: the same failure withreconnect: truedisconnects but keeps reconnecting.test_shutdown_while_disconnected_stops_reconnectingandtest_shutdown_with_reconnect_while_disconnected_keeps_reconnecting.I could not build this workspace locally, so I am relying on CI for the compile, clippy and test run.
This contribution is offered under the project's MIT licence.