mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-22 01:20:39 +00:00
Recently, the logic of elect_new_leader was changed to allow the old leader to vote for the new candidate. But the implementation is wrong as it re-connects the old leader in all cases disregarding if the nodes were already disconnected. Check if both old leader and the requested new leader are connected first and only if it is the case then the old leader can participate in the election. There were occasional hangs in the loop of elect_new_leader because other nodes besides the candidate were ticked. This patch fixes the loop by removing ticks inside of it. The loop is needed to handle prevote corner cases (e.g. 2 nodes). While there, also wait log on all followers to avoid a previously dropped leader to be a dueling candidate. And update _leader only if it was changed. Signed-off-by: Alejo Sanchez <alejo.sanchez@scylladb.com> Message-Id: <20210609193945.910592-3-alejo.sanchez@scylladb.com>