Conversation
Co-authored-by: Copilot <copilot@github.com>
There was a problem hiding this comment.
Code Review
This pull request introduces a new error code, TSDB_CODE_SYN_LEARNER_NO_VOTE, and implements a check in syncNodeOnRequestVote to prevent nodes in the learner state from participating in votes. Feedback indicates that this check is currently positioned before the term update logic, which violates the Raft protocol as learners must still update their current term when encountering a higher term. It is also suggested to return a standard Raft reply with the vote denied rather than an error code to prevent candidate timeouts.
There was a problem hiding this comment.
Pull request overview
This PR prevents Raft vote processing when a sync node is in the learner state, adding a dedicated error code to represent “learner cannot vote”.
Changes:
- Add a new sync error code
TSDB_CODE_SYN_LEARNER_NO_VOTEand its error string. - In
syncNodeOnRequestVote(), early-return when the node state isTAOS_SYNC_STATE_LEARNERto avoid voting.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
source/util/src/terror.c |
Adds human-readable error string for the new sync error code. |
include/util/taoserror.h |
Registers a new error code ID for “learner cannot vote”. |
source/libs/sync/src/syncRequestVote.c |
Rejects RequestVote handling when the node is in learner state. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description
Issue(s)
Checklist
Please check the items in the checklist if applicable.