Fix random election timeout rounds (srand(0) == srand(1) for glibc)

This commit is contained in:
Ruben S. Montero committed 2018-06-11 17:20:40 +02:00
1 parent d50141d5bc
commit 27403b3c97
1 file changed
+7 -2
+7 -2
View File
@@ -1040,11 +1040,16 @@ void RaftManager::request_vote()
logdb->update_raft_state(raft_state_xml);
srand(_server_id);
srand(_server_id+1);
ms = rand() % 500 + election_timeout.tv_sec * 1000
ms = rand() % 1000 + election_timeout.tv_sec * 1000
+ election_timeout.tv_nsec / 1000000;
oss.str("");
oss << "No leader found, starting new election in " << ms << "ms";
NebulaLog::log("RCM", Log::INFO, oss);
set_timeout(ms, etimeout);
nanosleep(&etimeout, 0);