Skip to content

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

Open
enjoy-binbin wants to merge 2 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 2 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: b97cf894-fbec-47f9-9173-9eafdd36cb7c

📥 Commits

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

📒 Files selected for processing (1)
  • tests/unit/cluster/info.tcl
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/unit/cluster/info.tcl

📝 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 ClusterHandlers
  participant clusterState
  participant ClusterInfo
  ClusterPeer->>ClusterHandlers: establish inbound or outbound link
  ClusterHandlers->>clusterState: increment corresponding counter
  ClusterInfo->>clusterState: read establishment totals
  clusterState-->>ClusterInfo: 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 new per-direction cluster link established counters added to CLUSTER INFO.
Description check ✅ Passed The description directly matches the changes by explaining the new inbound and outbound cluster link counters and their purpose.
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

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
Signed-off-by: Binbin <binloveplay1314@qq.com>
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.

1 participant