Skip to content

fix: [6980850041] avoid-vote-at-learner-state#35259

Open
cadem wants to merge 2 commits into3.3.6from
fix/dmchen/6980850041-avoid-vote-at-learner-state-3.3.6
Open

fix: [6980850041] avoid-vote-at-learner-state#35259
cadem wants to merge 2 commits into3.3.6from
fix/dmchen/6980850041-avoid-vote-at-learner-state-3.3.6

Conversation

@cadem
Copy link
Copy Markdown
Contributor

@cadem cadem commented Apr 29, 2026

Description

Issue(s)

  • Close/close/Fix/fix/Resolve/resolve: Issue Link

Checklist

Please check the items in the checklist if applicable.

  • Is the user manual updated?
  • Are the test cases passed and automated?
  • Is there no significant decrease in test coverage?

Co-authored-by: Copilot <copilot@github.com>
Copilot AI review requested due to automatic review settings April 29, 2026 07:20
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

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.

Comment thread source/libs/sync/src/syncRequestVote.c
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_VOTE and its error string.
  • In syncNodeOnRequestVote(), early-return when the node state is TAOS_SYNC_STATE_LEARNER to 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.

Comment thread source/libs/sync/src/syncRequestVote.c
@cadem cadem requested a review from zitsen as a code owner May 6, 2026 01:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants