Skip to content

Add per-direction cluster link established counter info fields - #4169

Open
enjoy-binbin wants to merge 3 commits into
valkey-io:unstablefrom
enjoy-binbin:cluster_link_fields
Open

Add per-direction cluster link established counter info fields#4169
enjoy-binbin wants to merge 3 commits into
valkey-io:unstablefrom
enjoy-binbin:cluster_link_fields

Conversation

@enjoy-binbin

Copy link
Copy Markdown
Member

Expose two new CLUSTER INFO counters to track cluster link:

  • total_cluster_links_established_inbound: inbound links
    successfully established with peers via accept
  • total_cluster_links_established_outbound: outbound links
    successfully established to peers via connect

Unlike the existing topology-derived cluster_connections field,
these are precise cumulative counters incremented when a link
is actually established (on accept, and on successful connect).
They help surface network flapping / frequent re-connections
between nodes.

Expose two new CLUSTER INFO counters to track cluster link:
- total_cluster_links_established_inbound: inbound links
  successfully established with peers via accept
- total_cluster_links_established_outbound: outbound links
  successfully established to peers via connect

Unlike the existing topology-derived cluster_connections field,
these are precise cumulative counters incremented when a link
is actually established (on accept, and on successful connect).
They help surface network flapping / frequent re-connections
between nodes.

Both fields can be reset by CONFIG RESETSTAT.

Signed-off-by: Binbin <binloveplay1314@qq.com>
@enjoy-binbin enjoy-binbin added the major-decision-pending Major decision pending by TSC team label Jul 15, 2026
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f066c4ff-20e7-4695-b560-08afc484ec5e

📥 Commits

Reviewing files that changed from the base of the PR and between e195918 and 7f903fa.

📒 Files selected for processing (1)
  • src/cluster_legacy.c
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/cluster_legacy.c

📝 Walkthrough

Walkthrough

Cluster link statistics now count successfully established inbound and outbound connections, expose both totals in cluster info, reset them with cluster statistics, and validate startup and reset behavior in unit tests.

Changes

Cluster Link Statistics

Layer / File(s) Summary
Track and report established links
src/cluster_legacy.h, src/cluster_legacy.c
Adds inbound and outbound counters, increments them when links are accepted or connected, and exposes their totals through cluster info.
Reset and validate counters
src/cluster.c, tests/unit/cluster/info.tcl
Resets both counters through CONFIG RESETSTAT and verifies startup thresholds plus post-reset zero values.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ClusterPeer
  participant clusterConnAcceptHandler
  participant clusterLinkConnectHandler
  participant clusterState
  participant genClusterInfoString
  ClusterPeer->>clusterConnAcceptHandler: accept inbound cluster link
  clusterConnAcceptHandler->>clusterState: increment inbound counter
  ClusterPeer->>clusterLinkConnectHandler: establish outbound cluster link
  clusterLinkConnectHandler->>clusterState: increment outbound counter
  genClusterInfoString->>clusterState: read establishment totals
  clusterState-->>genClusterInfoString: inbound and outbound totals
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding per-direction cluster link establishment counters.
Description check ✅ Passed The description directly matches the change by explaining the new inbound and outbound CLUSTER INFO counters.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@enjoy-binbin
enjoy-binbin requested a review from a team July 15, 2026 03:19

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/unit/cluster/info.tcl`:
- Around line 64-65: Update the second assertion in the cluster link checks to
validate node 2’s inbound counter instead of repeating
total_cluster_links_established_outbound, while preserving the existing
threshold and outbound assertion.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9e99d1ea-5519-4a6d-8e33-33dddc0e2fd4

📥 Commits

Reviewing files that changed from the base of the PR and between 050b065 and b2cf989.

📒 Files selected for processing (4)
  • src/cluster.c
  • src/cluster_legacy.c
  • src/cluster_legacy.h
  • tests/unit/cluster/info.tcl

Comment thread tests/unit/cluster/info.tcl Outdated

@valkey-review-bot valkey-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation looks correct — counters increment only after the connection-state checks in both handlers, and reset/init via resetClusterStats() is covered. One copy-paste issue in the new test.

Comment thread tests/unit/cluster/info.tcl Outdated
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.85%. Comparing base (6b006c9) to head (7f903fa).

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #4169      +/-   ##
============================================
+ Coverage     76.81%   76.85%   +0.04%     
============================================
  Files           162      162              
  Lines         81455    81459       +4     
============================================
+ Hits          62570    62609      +39     
+ Misses        18885    18850      -35     
Files with missing lines Coverage Δ
src/cluster.c 92.68% <100.00%> (+0.25%) ⬆️
src/cluster_legacy.c 88.19% <100.00%> (-0.02%) ⬇️

... and 15 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@murphyjacob4 murphyjacob4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems useful

@valkey-io/core-team vote for new established cluster link info field: 👍/👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

major-decision-pending Major decision pending by TSC team

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants