After election timer is changed through cluster/change-election-timer
command, if a server restarts, it firstly initializes with the default
value and use it to reset the timer. Although it reads the latest
timer value later from the log, the first timeout may be much shorter
than expected by other servers that use latest timeout, and it would
start election before it receives the first heartbeat from the leader.
This patch fixes it by changing the order of reading log and resetting
timer so that the latest value is read from the log before the initial
resetting of the timer.
Fixes: commit 8e35461 ("ovsdb raft: Support leader election time change online.")
Signed-off-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
hmap_init(&raft->commands);
raft->election_timer = ELECTION_BASE_MSEC;
- raft_reset_ping_timer(raft);
- raft_reset_election_timer(raft);
return raft;
}
raft->join_timeout = time_msec() + 1000;
}
+ raft_reset_ping_timer(raft);
+ raft_reset_election_timer(raft);
+
*raftp = raft;
hmap_insert(&all_rafts, &raft->hmap_node, hash_string(raft->name, 0));
return NULL;