Skip to content

Sometimes receive "Not leader" response from leader in OnStartingFollowing() #31

@atellwu

Description

@atellwu

Describe the bug

image

  • Problem:
    • OnStartingFollowing(): When you add Node to leader, you receive a response from leader that returns "Not leader" (our own implementation).
  • Reason
    • In the internal process of jraft, node becomes leader - > sends leader heartbeat to all nodes - > other nodes become follower (asynchronous callback onStarting Following) - > leader receives all follower ACK (asynchronous callback onLeaderStart).
    • So visit leader in onStarting Following, and leader will report "Not leader" because it has not yet executed onLeaderStart (because our code sets leaderTerm in onLeaderStart).
  • Restoration plan
    • Do not judge leader based on leaderTerm, but directly on Node.isLeader().
  • Interim plan
    • In the short term, you can sleep in on StartingFollowing() for a few seconds (for example, 3s) and then visit the leader.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions