title: How can a node with complete log can be elected if another becomes a candidate first?
body: <p>I've been watching Raft Algorithm video at <a href="https://youtu.be/vYp4LYbnnW8?t=3244" rel="nofollow noreferrer">https://youtu.be/vYp4LYbnnW8?t=3244</a>, but am not clear about one circumstance.</p>
  
  <p><a href="https://i.stack.imgur.com/mAxh1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mAxh1.png" alt="Leader Election"></a></p>
  
  <p>In leader election for term 4, if node s1 broadcasts RequestVote before s3 does then node s2, s4 and s5 would vote for it, while s3 doesn't.  And then node s3 broadcasts RequestVote to others, how can it get the vote of others?</p>
  
  <p>One possible way to handle the situation I can figure out is:</p>
  
  <ol>
  <li>if node s1 receives the rejection from s3, and found out s3's log is newer than itself, and do not set itself as leader even though it receives majority of votes</li>
  <li>As to other nodes, they remember the leader information they voted, if a new vote request comes (with bigger <code>&lt;lastTerm, lastIndex&gt;</code>), they vote for the node with bigger <code>&lt;lastTerm, lastIndex&gt;</code>.</li>
  </ol>
  
  <p>In both scenarios, eventually node s3 gets all others' votes, and sets itself as leader. I'm not sure if my guess is correct.</p>