support updating raft-max-inflight-msgs setting#582
support updating raft-max-inflight-msgs setting#582glorv wants to merge 1 commit intotikv:masterfrom
Conversation
Signed-off-by: glorv <glorvs@163.com>
📝 WalkthroughWalkthroughAdded functionality to dynamically adjust the maximum inflight replication messages in a Raft cluster. Three new methods enable updating the cap across the raft instance, progress tracker, and individual inflight entries, with a unit test validating the behavior including preservation of per-peer overrides. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 Tip You can disable poems in the walkthrough.Disable the |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/raft.rs (2)
2967-2971: Clean up public API doc wording/typos.There are a few doc typos and grammar issues around the new API description (e.g.,
max_inflight_megs,update,overrided,must greater).✏️ Suggested doc cleanup
- /// Adjust the `max_inflight_megs` setting for this raft group. - /// This function update the `max_inflight` for the whole raft group for any - /// existing peers (if their existing settings are not explicitly overrided) + /// Adjust the `max_inflight_msgs` setting for this raft group. + /// This function updates `max_inflight` for the whole raft group for any + /// existing peers (if their existing settings are not explicitly overridden) /// as well as any incoming peers (via ProgressTracker::apply_conf). - /// The config value must greater than 0. + /// The config value must be greater than 0.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/raft.rs` around lines 2967 - 2971, Fix the public API doc for the max-inflight setting: update the comment for the function that adjusts `max_inflight_megs` so it reads clearly and fixes typos — e.g. "Adjust the `max_inflight_megs` setting for this raft group." then "This function updates the `max_inflight` for the whole raft group for any existing peers (if their existing settings are not explicitly overridden) as well as for any incoming peers (via ProgressTracker::apply_conf)." and finish with "The config value must be greater than 0." Ensure references to `max_inflight_megs`, `max_inflight`, and `ProgressTracker::apply_conf` remain intact.
2994-3011: Add one test assertion for newly added peers after global update.This test validates existing-peer propagation and override preservation well, but it does not yet verify the “incoming peers use updated cap” path from the PR objective. Please add a follow-up case that adds a new peer after Line 3004 and checks its inflight cap is
512.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/raft.rs` around lines 2994 - 3011, In the test test_adjust_raft_max_inflight_msgs_preserves_peer_overrides, after you call raft.adjust_raft_max_inflight_msgs(512) add a new peer and assert it receives the updated global cap: create a new Peer via raft.mut_prs().get_mut(<new_peer_id>) (e.g., 4), call its ins.add(...) if needed, then assert its ins.get_cap() == 512 to verify newly added peers inherit the global max_inflight; keep existing assertions unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed. Nitpick comments: In `@src/raft.rs`: - Around line 2967-2971: Fix the public API doc for the max-inflight setting: update the comment for the function that adjusts `max_inflight_megs` so it reads clearly and fixes typos — e.g. "Adjust the `max_inflight_megs` setting for this raft group." then "This function updates the `max_inflight` for the whole raft group for any existing peers (if their existing settings are not explicitly overridden) as well as for any incoming peers (via ProgressTracker::apply_conf)." and finish with "The config value must be greater than 0." Ensure references to `max_inflight_megs`, `max_inflight`, and `ProgressTracker::apply_conf` remain intact. - Around line 2994-3011: In the test test_adjust_raft_max_inflight_msgs_preserves_peer_overrides, after you call raft.adjust_raft_max_inflight_msgs(512) add a new peer and assert it receives the updated global cap: create a new Peer via raft.mut_prs().get_mut(<new_peer_id>) (e.g., 4), call its ins.add(...) if needed, then assert its ins.get_cap() == 512 to verify newly added peers inherit the global max_inflight; keep existing assertions unchanged. ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 22ac2f20-0535-42d7-9980-d4d2df5fef18
📒 Files selected for processing (3)
src/raft.rssrc/tracker.rssrc/tracker/inflights.rs
| /retest |
| /test |
The current impl only provide function
Raft::adjust_max_inflight_msgsthat changes the inflight cap of a specific peer. So even when we set all the peers' cap with this function, any incoming peer's cap will still be set with the initial inflight cap. This is not what we want when we want to update the global setting which should update the max_inflight_msgs for all existing and incoming peers.So this PR add a new function
set_raft_max_inflight_msgsto support updating the max_inflight setting.