Skip to content

v4: absorb main 3.5.0, part 7 - sentinel replica reconcile, READONLY role re-read (#3385, #3391, #3384) - #3411

Merged
mgravell merged 3 commits into
v4from
marc/v4-absorb-3.5-c2
Dec 3, 2026
Merged

mgravell merged 3 commits into
v4from
marc/v4-absorb-3.5-c2

Conversation

@mgravell

@mgravell mgravell commented Dec 3, 2026

Copy link
Copy Markdown
Member

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).

#3382 (reroute away from a LOADING replica) will be its own PR. Re-issuing on v4 needs to tell an IServer-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.
  • Wider suites: sentinel (incl. the new SentinelReplicaReconcileUnitTests), failover, read-only, role, topology, connect, cluster, retire, replica, subscription, loading and SanityChecks pass. net10.0: 856 (78 skipped). net481: 843 (96 skipped).

… 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".
@mgravell
mgravell merged commit d223ac7 into v4 Dec 3, 2026
4 of 5 checks passed
@mgravell
mgravell deleted the marc/v4-absorb-3.5-c2 branch December 3, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant