willemt / raft

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

potential race condition in removing/adding same node? #119

Open skygragon opened 3 years ago

skygragon commented 3 years ago

say we remove node the add it back as non-voting, seems there would be race condition to cause a crash?

  1. append log "remove node A"
  2. append log "add non-voting node A" => new node memory
  3. later apply log "remove node A" => free node memory
  4. apply log "add non-voting node A" => update node memory (oops!)