Repository navigation
fix: [#4696] HA/Raft auto-reset a follower's wedged replication chann… - #5020
Conversation
…el (Gap 1) Closes the remaining Gap 1 from issue #4696: after a follower restarts with a new address (e.g. a Kubernetes pod-IP change), the leader's outbound Ratis gRPC appender channel could stay wedged on a stale/negative DNS result indefinitely, stranding the follower until a manual transferLeadership. Ratis's own error path only calls GrpcServerProtocolClient.resetConnectBackoff(), which never recreates the ManagedChannel or re-resolves DNS, so the earlier fix (proactive allowlist refresh + JVM DNS TTL) was not enough on its own. Now the leader, once a follower has stayed continuously unreachable (no successful RPC) for arcadedb.ha.peerChannelResetDuration (default 60s), closes that one follower's outbound gRPC proxy via PeerProxyMap.resetProxy(). The appender's next send rebuilds a fresh ManagedChannel against the same peer DNS name, which re-resolves to the follower's current IP and reconnects. Only the unreachable peer's channel is touched and leadership is unchanged, so there is no flapping risk - a less-disruptive automatic alternative to the manual leadership-transfer lever. Set the duration to 0 to disable. Uses the public Ratis PeerProxyMap.resetProxy API (no reflection); the detection reuses the leader's existing per-follower unreachability signal in ClusterMonitor, fires once per unreachable streak, and re-arms on reconnect. Tests: ClusterMonitorTest (trigger fires once after the reset duration, re-arms after reconnect, disabled when duration=0, handler required when enabled) and RaftPeerChannelResetTest (the resetProxy coupling seam, plus graceful no-op when the RPC layer is not proxy-based).
|
Tick the box to add this pull request to the merge queue (same as
|
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 31 |
🟢 Coverage 80.00% diff coverage · -7.21% coverage variation
Metric Results Coverage variation ✅ -7.21% coverage variation Diff coverage ✅ 80.00% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (593f621) 134803 100334 74.43% Head commit (a9961a4) 166670 (+31867) 112041 (+11707) 67.22% (-7.21%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#5020) 65 52 80.00% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Code Review
This pull request introduces an automatic channel-reset recovery mechanism to handle cases where a follower's replication channel becomes wedged on stale DNS after a pod-IP change in Kubernetes. It adds a new configuration parameter arcadedb.ha.peerChannelResetDuration and updates ClusterMonitor and RaftHAServer to reset the Ratis gRPC proxy channel for continuously unreachable peers. The changes are well-tested with new unit tests. The reviewer suggested adding a defensive null check on withProxy.getProxies() in RaftHAServer.resetPeerAppenderChannel to prevent a potential NullPointerException.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| static boolean resetPeerAppenderChannel(final RaftServerRpc rpc, final RaftPeerId peerId) { | ||
| if (rpc instanceof RaftServerRpcWithProxy<?, ?> withProxy) { | ||
| withProxy.getProxies().resetProxy(peerId); | ||
| return true; | ||
| } | ||
| return false; | ||
| } |
There was a problem hiding this comment.
To prevent a potential NullPointerException, it is safer to perform a defensive null check on withProxy.getProxies() before invoking resetProxy(peerId). While getProxies() is typically non-null in standard Ratis implementations, adding a null check aligns with defensive programming best practices and ensures robustness.
static boolean resetPeerAppenderChannel(final RaftServerRpc rpc, final RaftPeerId peerId) {
if (rpc instanceof RaftServerRpcWithProxy<?, ?> withProxy) {
final var proxies = withProxy.getProxies();
if (proxies != null) {
proxies.resetProxy(peerId);
return true;
}
}
return false;
}
Review: HA/Raft auto-reset of a wedged replication channel (#4696)Overall this is a well-scoped, well-documented fix. It reuses the existing per-follower unreachability signal in A few points worth considering: 1. Single-fire-per-streak may not be robust enough (medium)
Consider re-arming periodically while the streak continues, e.g. re-fire every 2. Silent coupling to
|
…derChannel Address Gemini review on PR #5020: guard against a null PeerProxyMap before calling resetProxy() so a proxy-based RPC whose proxy map is not yet available is a safe no-op instead of a potential NPE. Add a regression test for the null-proxies path.
|
Review: HA/Raft auto-reset of a follower wedged replication channel (issue 4696) Overall this is a well-scoped, well-documented fix. The single-peer channel reset (vs. a full transferLeadership) is the right lever, the public PeerProxyMap.resetProxy API avoids reflection, the disable switch (=0) is a good safety valve, and the tests cover the streak fire-once / re-arm / disabled / handler-required cases plus the Ratis seam. The Javadoc and release note are excellent. A few points worth considering: 1. The reset is single-shot per streak - a failed reset can leave the follower stranded (the exact failure mode being fixed). 2. Implicit coupling to HA_PEER_UNREACHABLE_THRESHOLD. 3. ClusterMonitor logs the reset at WARNING even when the handler is a no-op. 4. Minor: raftServer read from the lag-monitor thread. Nits. Nothing here is blocking - point 1 is the one I would most encourage addressing, since a single failed reset re-introduces the stranding this PR aims to prevent. |
… + log clarity Address review feedback on PR #5020: 1. Single-shot reset could re-strand the follower. If the first resetProxy did not heal the channel (e.g. the rebuilt channel re-resolves stale DNS while the JVM positive-cache TTL has not expired), the streak never ended and no further reset was attempted - reproducing the stranded-until-manual-transferLeadership symptom this fix targets. The reset is now retried once per peerChannelResetDuration while the follower stays unreachable, bounded by CHANNEL_RESET_MAX_ATTEMPTS (5); after the cap the monitor gives up and logs once (SEVERE) for operator intervention. The counter re-arms on reconnect. An in-progress reconnection is not disrupted: a follower that returns within an interval clears the streak and is never reset. 2. Implicit coupling to peerUnreachableThreshold was silent. Setting arcadedb.ha.peerUnreachableThreshold=0 disabled the channel reset even with peerChannelResetDuration > 0. ClusterMonitor now logs a WARNING at construction when the reset is enabled but its unreachable signal is disabled. 3. Over-promising WARNING. ClusterMonitor logged "resetting" at WARNING before invoking the handler, so a no-op (non-proxy RPC) still announced a reset, and a success logged two WARNINGs (monitor + server). The monitor now announces intent ("triggering ... attempt N/M"), RaftHAServer confirms a success at FINE, and surfaces the rare no-op at WARNING - one operator-facing WARNING per reset. Tests: rewrote the sustained-unreachability test for periodic retry, added the give-up cap test and the misconfiguration-warning tests.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #5020 +/- ##
============================================
+ Coverage 65.44% 65.46% +0.01%
- Complexity 821 839 +18
============================================
Files 1687 1687
Lines 134803 134867 +64
Branches 28824 28836 +12
============================================
+ Hits 88226 88291 +65
Misses 34506 34506
+ Partials 12071 12070 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
… + log clarity Address review feedback on PR #5020: 1. Single-shot reset could re-strand the follower. If the first resetProxy did not heal the channel (e.g. the rebuilt channel re-resolves stale DNS while the JVM positive-cache TTL has not expired), the streak never ended and no further reset was attempted - reproducing the stranded-until-manual-transferLeadership symptom this fix targets. The reset is now retried once per peerChannelResetDuration while the follower stays unreachable, bounded by CHANNEL_RESET_MAX_ATTEMPTS (5); after the cap the monitor gives up and logs once (SEVERE) for operator intervention. The counter re-arms on reconnect. An in-progress reconnection is not disrupted: a follower that returns within an interval clears the streak and is never reset. 2. Implicit coupling to peerUnreachableThreshold was silent. Setting arcadedb.ha.peerUnreachableThreshold=0 disabled the channel reset even with peerChannelResetDuration > 0. ClusterMonitor now logs a WARNING at construction when the reset is enabled but its unreachable signal is disabled. 3. Over-promising WARNING. ClusterMonitor logged "resetting" at WARNING before invoking the handler, so a no-op (non-proxy RPC) still announced a reset, and a success logged two WARNINGs (monitor + server). The monitor now announces intent ("triggering ... attempt N/M"), RaftHAServer confirms a success at FINE, and surfaces the rare no-op at WARNING - one operator-facing WARNING per reset. Tests: rewrote the sustained-unreachability test for periodic retry, added the give-up cap test and the misconfiguration-warning tests. (cherry picked from commit a9961a4)
…el (Gap 1)
Closes the remaining Gap 1 from issue #4696: after a follower restarts with a new address (e.g. a Kubernetes pod-IP change), the leader's outbound Ratis gRPC appender channel could stay wedged on a stale/negative DNS result indefinitely, stranding the follower until a manual transferLeadership. Ratis's own error path only calls GrpcServerProtocolClient.resetConnectBackoff(), which never recreates the ManagedChannel or re-resolves DNS, so the earlier fix (proactive allowlist refresh + JVM DNS TTL) was not enough on its own.
Now the leader, once a follower has stayed continuously unreachable (no successful RPC) for arcadedb.ha.peerChannelResetDuration (default 60s), closes that one follower's outbound gRPC proxy via PeerProxyMap.resetProxy(). The appender's next send rebuilds a fresh ManagedChannel against the same peer DNS name, which re-resolves to the follower's current IP and reconnects. Only the unreachable peer's channel is touched and leadership is unchanged, so there is no flapping risk - a less-disruptive automatic alternative to the manual leadership-transfer lever. Set the duration to 0 to disable.
Uses the public Ratis PeerProxyMap.resetProxy API (no reflection); the detection reuses the leader's existing per-follower unreachability signal in ClusterMonitor, fires once per unreachable streak, and re-arms on reconnect.
Tests: ClusterMonitorTest (trigger fires once after the reset duration, re-arms after reconnect, disabled when duration=0, handler required when enabled) and RaftPeerChannelResetTest (the resetProxy coupling seam, plus graceful no-op when the RPC layer is not proxy-based).
What does this PR do?
A brief description of the change being made with this pull request.
Motivation
What inspired you to submit this pull request?
Related issues
A list of issues either fixed, containing architectural discussions, otherwise relevant
for this Pull Request.
Additional Notes
Anything else we should know when reviewing?
Checklist
mvn clean packagecommand