fix: ask the peers, not the node, whether a cluster member is failing - #442
melancholictheory wants to merge 1 commit into
Conversation
GetSyncedReplicas and countReadyShards excluded a node when its own Flags
held "fail" or "pfail". Neither clause could ever match. "pfail" is not a
token Valkey emits: CLUSTER_NODE_PFAIL renders as "fail?". And node.Flags
holds the node's own "myself" line, which never carries a failure flag,
because a node does not mark itself failing; clusterCron skips myself when
setting PFAIL. Failure is something the peers report about a node.
Both sites now use ClusterState.IsNodeFailed, which walks every live node's
CLUSTER NODES output for the id and matches "fail" and "fail?".
GetSyncedReplicas takes the cluster state to do so; findFailoverShard, its
only caller, already holds it.
The old check looked covered because TestShardState_GetSyncedReplicas fed it
replicas with Flags {"slave","fail"} and {"slave","pfail"}, states that do not
occur, and asserted they were excluded. That fixture is replaced by a replica
whose own scrape is clean and whose primary reports it as "fail?", the case
the check exists for. countReadyShards gets its first test with the same
shape, and findFailoverShard a case where the only replica is peer-reported
failing and is therefore not a failover target.
Closes valkey-io#441
Signed-off-by: melancholictheory <selimvhorst@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (6)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughThe change replaces ineffective self-reported node flag checks with peer-reported failure checks. ChangesPeer-reported failure handling
Suggested reviewers: Priority: ➖ Normal Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The change correctly excludes peer-reported failed replicas from readiness and failover decisions. No actionable merge risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Warning Some tools did not complete. Review the errors below. 🔧 golangci-lint (2.13.2)Error: build linters: plugin(logcheck): plugin "logcheck" not found Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
This PR closes #441.
Summary
GetSyncedReplicasandcountReadyShardsboth guard onand neither half can ever be true.
pfailis not a token Valkey emits;CLUSTER_NODE_PFAILrenders asfail?. Andnode.Flagsis the node's ownmyselfline, which never carries a failure flag, because a node does not mark itself failing (clusterCronskipsmyselfwhen setting PFAIL). A failure flag on a node is set by its peers, not by the node.Both sites now ask the peers through
ClusterState.IsNodeFailed, which already existed and already matchesfailandfail?.Features / Behaviour Changes
countReadyShardsno longer counts a shard ready while a node in it, still reachable by the operator, is reportedfail?orfailby its peers. Before, that shard passed, and if the flagged node was the primary nothing downstream stopped it either, sinceIsReplicationInSyncreturns true for any primary.GetSyncedReplicasno longer offers such a replica as a failover target. In practice the neighbouringmaster_link_status != "up"check caught most of these already, so the visible change there is small.An unreachable node is unaffected: it never enters
shard.Nodes, and the node-count check handles it as before.Implementation
GetSyncedReplicastakes*ClusterState.findFailoverShard, its only production caller, already holds it.countReadyShardsalready hadstatein scope.Testing
make testandpre-commit run --all-files.The old check looked covered.
TestShardState_GetSyncedReplicasbuilt replicas withFlags: {"slave", "fail"}and{"slave", "pfail"}, states that cannot occur, and asserted they were excluded. The test handed the check the exact strings it looked for. That fixture is replaced by a replica whose own scrape is clean and whose primary reports it asfail?, the same shapeTestClusterState_IsNodeFaileduses.countReadyShardshad no test;TestCountReadyShardscovers a healthy shard and a shard with a present node the primary reportsfail?.TestFindFailoverShardgains a case where the only replica is peer-reported failing.All three new cases fail with the old checks reinstated behind the new signatures and pass with the fix.
Checklist
pre-commit run --all-filesor hooks on commit)Signed-off-by: melancholictheory selimvhorst@gmail.com