Repository navigation
v4: absorb main 3.5.0, part 7 - sentinel replica reconcile, READONLY role re-read (#3385, #3391, #3384) - #3411
Merged
Merged
Conversation
… a new primary (#3385) * Sentinel: follow the replicas sentinel lists, not only on a switch to a new primary A managed connection read SENTINEL REPLICAS only at connect and when a switch named a primary at an address it had never seen. A replica that left stayed held, its bridge reconnecting for the life of the connection; one that joined was never used (#3378). The managed connection's replicas are now reconciled every ConfigCheckSeconds from the sentinel connection's heartbeat, and at the next heartbeat after +slave or +reset-master: - a listed replica we do not hold is added once sentinel does not hold it down (s_down/o_down/disconnected), so a replica down during a rolling restart joins on a later run; - a node is retired only when it is not the sentinel-reported primary, is disconnected, and three consecutive periodic replies leave it out or hold it down. A connected node is kept whatever sentinel says; an empty reply, or a run an event started, retires nothing. It stands aside while a switch, reconnect or reconfigure is running, and holds the reconfigure gate while it changes the endpoint set. Claude-Session: https://claude.ai/code/session_01DUpQ8dy8FLBwADei2VzLmZ * Move the replica log event beside the server-retirement one Claude-Session: https://claude.ai/code/session_01DUpQ8dy8FLBwADei2VzLmZ * Update #3301's sentinel tests for the replica reconcile Three tests asserted that a dead replica stays held, or that a newly listed one is not added, with no change of primary. That is the behaviour #3378 changes: with ConfigCheckSeconds = 1 the reconcile retires such a replica after about three seconds, so the assertions raced it (and lost on net481 in CI). They now wait for the replica set to follow sentinel, and keep their checks that primary recovery is not kept alive. Claude-Session: https://claude.ai/code/session_01DUpQ8dy8FLBwADei2VzLmZ
…) (#3392) Under sentinel, the connect-failure refresh re-read the endpoints we already hold, dialling the dead node while holding the reconfigure gate. Repeated every interval, that starved the replica reconcile (which stands aside while the gate is held), so a dead replica sentinel had dropped was never retired. Sentinel is what follows the topology there, so a sentinel-managed connection now skips the refresh, as it already defers READONLY handling to the sentinel owner.
…t sentinel (port of main #3384) A primary demoted in place (REPLICAOF, or a sentinel failover whose +switch-master was missed) drops no connection, so writes kept going to it until the next periodic role check. A READONLY reply from a node still treated as a primary now re-reads the role of every connected node, at most once a second per multiplexer (main's OnReadOnlyReply / TryClaimReadOnlyRoleCheck). On v4 the hook is the READONLY check in RespClientConnection.TryHandOff (added for #3301), which now splits as main's ResultProcessor does: sentinel-managed marks the node as a replica, otherwise OnReadOnlyReply. The re-read is TryRefreshRole (ROLE) rather than INFO replication. Test adjustments: ReadOnlyReplyUnitTests counts ROLE as a role read too; and in the window between the demotion being noticed and the new primary elected, v4 refuses the write client-side (the node is now known to be a replica) where v3 had no connection, so both count as "no writable server yet".
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.
Seventh slice of absorbing main's 3.5.0 into v4, following #3410: the rest of the sentinel/topology batch except #3382. Three commits, kept separate for review (the merge squashes them).
CheckManagedReplicasDuebeside v4's subscription retry and retirement passes.ServerEndPoint.OnRepeatedConnectFailurefromRespEndpointExecutoron repeated dial failures, so the guard applies as on main.READONLY(without sentinel). Ported:READONLYcheck that v4: absorb main 3.5.0, part 6 - sentinel: async discovery and recovery (#3301) #3410 added toRespClientConnection.TryHandOff. It now splits as main'sResultProcessordoes: a sentinel-managed connection marks the node as a replica; anything else callsOnReadOnlyReply.TryRefreshRole(ROLE), at most once a second, instead ofINFO replication.ReadOnlyReplyUnitTestscountsROLEas a role read.#3382 (reroute away from a
LOADINGreplica) will be its own PR. Re-issuing on v4 needs to tell anIServer-pinned command from a routed one, and today the two share the same endpoint executors, so that takes some plumbing.Tests
ReadOnlyReplyUnitTests: three clean runs. After the switch, writes recover within about 20ms. The rate limit holds: 3 role reads in about 70k refusals over 2.7s.SentinelReplicaReconcileUnitTests), failover, read-only, role, topology, connect, cluster, retire, replica, subscription, loading and SanityChecks pass. net10.0: 856 (78 skipped). net481: 843 (96 skipped).