-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: sikp readindex to slow followers #1234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: jeremyhi <[email protected]>
WalkthroughIntroduces an optimization to reduce lock contention during read index request handling by filtering followers based on replication lag. Adds a new lock-free method to check replication progress without acquiring locks, and updates configuration documentation to support the new filtering threshold. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Leader
participant FollowerA as Follower A<br/>(in-sync)
participant FollowerB as Follower B<br/>(lagging)
rect rgb(200, 220, 255)
Note over Leader,FollowerB: Previous behavior: ReadIndex broadcast to all followers
Client->>Leader: ReadIndex request
Leader->>Leader: handleReadIndexRequest()
Leader->>FollowerA: sendHeartbeat() + lock contention
Leader->>FollowerB: sendHeartbeat() + lock contention
end
rect rgb(220, 240, 200)
Note over Leader,FollowerB: New behavior: ReadIndex broadcast to filtered peers only
Client->>Leader: ReadIndex request
Leader->>Leader: handleReadIndexRequest()
Leader->>Leader: filterPeersForReadIndex()<br/>using getNextIndexUnsafe()
alt Lag within threshold
Leader->>FollowerA: sendHeartbeat() (reduced contention)
else Lag exceeds threshold
Leader->>FollowerB: skip (no lock acquisition)
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
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 |
Motivation:
Explain the context, and why you're making that change.
To make others understand what is the problem you're trying to solve.
As the title
Result:
Fixes #1232.
If there is no issue then describe the changes introduced by this PR.
Summary by CodeRabbit
Release Notes
New Features
maxReadIndexLagconfiguration parameter to control when this optimization is applied (disabled by default with-1).Enhancements