willemt / raft

C implementation of the Raft Consensus protocol, BSD licensed
Other
1.13k stars 271 forks source link

Possible issues #102

Open clicx opened 5 years ago

clicx commented 5 years ago

I have done the following testing:

  1. I applied one log item to three nodes, and persisted.
  2. delete persist data from one node (not leader) and start raft (other nodes keep alive).
  3. raft log will not be applied for this node, there is some log on this node: raft: AE no log at prev_idx 1 send: {"myid": 1, "message_type": "append_entries_response", "term": 1, "success": 0, "current_idx": 0, "first_idx": 2}

Then it will be loopback forever.

clicx commented 5 years ago

Is here problem? Because current node has no entry, ety always null therefor cause endless loop

/ Not the first appendentries we've received / / NOTE: the log starts at 1 / if (0 < ae->prev_log_idx) { raft_entry_t* ety = raft_get_entry_fromidx(me, ae->prev_log_idx);

    /* 2. Reply false if log doesn't contain an entry at prevLogIndex
       whose term matches prevLogTerm (§5.3) */
    if (!ety)
    {
        __log(me_, node, "AE no log at prev_idx %d", ae->prev_log_idx);
        goto out;
    }