Skip to content

v4: absorb main 3.5.0, part 6 - sentinel: async discovery and recovery (#3301) - #3410

Merged
mgravell merged 1 commit into
v4from
marc/v4-absorb-3.5-c
Dec 3, 2026
Merged

mgravell merged 1 commit into
v4from
marc/v4-absorb-3.5-c

Conversation

@mgravell

@mgravell mgravell commented Dec 3, 2026

Copy link
Copy Markdown
Member

Sixth slice of absorbing main's 3.5.0 into v4 (after #3403, #3406–#3409), and the first of the sentinel batch: main's #3301.

What carries over unchanged

Main's sentinel file applies as-is: async discovery, held-down primaries, seeded connections, switch replay and a sync connect that blocks no worker. The one exception is the role re-read for a reported primary that is still a replica. On v4 that goes through TryRefreshRole (ROLE), not main's CheckInfoReplicationAsync (INFO via the old bridge). Main's tests and docs/Configuration.md come across too.

Mapped onto v4

  • READONLY on a sentinel-managed connection. Main hooks ResultProcessor's common error handling; v4 does the same in RespClientConnection.TryHandOff, which sees every reply. It only marks the node as a replica; the sentinel heartbeat resolves the primary.
  • ConnectImplAsync gains main's endpoints/synchronousConnect parameters alongside v4's groupClientCache.

Two v4 core bugs the new tests exposed

  • Roles were never re-read on a sentinel-managed connection. RespTopology.WantsRoles was decided from the configured endpoints. A sentinel-managed connection is configured with the sentinel and handed the primary and replicas separately, so a reconfigure never asked ROLE. After a switch to a primary it hadn't seen, the demoted node stayed recorded as a primary for good (SwitchRequestedDuringDiscoveryIsReplayed). It now uses the multiplexer's own endpoints, and is always on for a sentinel-managed (non-sentinel) multiplexer.
  • A retired server could be brought back. The core's per-endpoint callbacks created a ServerEndPoint when asked for one. Sometimes a heartbeat role read captured an executor just before its endpoint was retired. Its ROLE then failed with "no connection", and describing that failure re-created the server, which kept the client on the node sentinel had told it to leave. This failed SeededClientLeavesTheSentinelHost… intermittently, and only under full-suite load; a probe in a failing run pinned it to that path. ModelledServer was documented as "if it models one", and it and the no-connection message now only look the server up.

Test adjustments for v4

  • HandlerSubscribedWhileStuckReceivesMessagesAfterRecovery: v4 doesn't queue a subscribe that has no server. It registers the handler and completes, and the subscription is restored on connect. What the test is about (the handler receives messages after recovery) holds.
  • FailedInfoWriteDoesNotCountAsAReplicationCheck asks TryRefreshRole.
  • ConnectionsTo counts the dedicated subscription socket through the core: v4's IsSubscriberConnected says subscriptions are available, not that their lazily dialled socket is open.

Tests

  • Sentinel classes (129) pass repeatedly, including 12 runs four-wide in parallel.
  • Full net10.0 suite, twice against my local servers: the same 112 failures as current v4 (newer server commands / full topology), and none only on this branch. Before the retire fix, the seeded-client case was the one extra failure in 3 of 4 full runs.
  • net481: sentinel, failover, pub/sub, topology, connect, cluster, retire and SanityChecks pass (925 tests, 137 skipped).

…port of main #3301)

Main's sentinel rework applies to v4 almost unchanged: the sentinel file is main's, with the role
re-read for a reported primary that is still a replica going through v4's TryRefreshRole (ROLE)
rather than main's CheckInfoReplicationAsync (INFO via the old bridge).

- READONLY on a sentinel-managed connection: main hooks ResultProcessor's common error handling;
  v4 does the same in RespClientConnection.TryHandOff, which sees every reply. It only marks the
  node as a replica; the sentinel heartbeat resolves the primary.
- ConnectImplAsync gains main's endpoints and synchronousConnect parameters alongside v4's
  groupClientCache.

Two v4 core bugs the new tests exposed:

- RespTopology.WantsRoles was decided from the configured endpoints. A sentinel-managed connection
  is configured with the sentinel and handed the primary and replicas separately, so it never
  re-read roles on a reconfigure, and a switch to a primary it had not seen left the demoted node
  recorded as a primary for good (SwitchRequestedDuringDiscoveryIsReplayed). It now uses the
  multiplexer's own endpoints, and is always on for a sentinel-managed (non-sentinel) multiplexer.
- The core's per-endpoint callbacks created a ServerEndPoint when asked for one. A heartbeat role
  read that captured an executor just before its endpoint was retired failed with "no connection",
  and describing that failure re-created the retired server, which then kept the client on the node
  sentinel had told it to leave (SeededClientLeavesTheSentinelHost..., intermittently, under load).
  ModelledServer, and the no-connection message, now only look the server up.

Test adjustments for v4:
- HandlerSubscribedWhileStuckReceivesMessagesAfterRecovery: v4 does not queue a subscribe with no
  server; it registers the handler and completes, and the subscription is restored on connect.
  The test's point (the handler receives messages after recovery) holds.
- FailedInfoWriteDoesNotCountAsAReplicationCheck asks TryRefreshRole.
- ConnectionsTo counts the dedicated subscription socket via the core: v4's IsSubscriberConnected
  says subscriptions are available, not that their lazily dialled socket is open.
@mgravell
mgravell merged commit b6ba7d3 into v4 Dec 3, 2026
3 checks passed
@mgravell
mgravell deleted the marc/v4-absorb-3.5-c branch December 3, 2026 19:15
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.

2 participants