1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-16 22:50:10 +03:00

development: Fix race condition between the expiration of the replica timeout and the pending_requests state change.

(cherry picked from commit 8693ac5cfecf57baa7b43015b9ba4b3958a4a612)
This commit is contained in:
Ruben S. Montero 2019-02-18 15:45:28 +01:00
parent b25042ab53
commit 4e4d1d0c41
2 changed files with 12 additions and 7 deletions

View File

@ -589,11 +589,11 @@ void RaftManager::replicate_log(ReplicaRequest * request)
}
//Count servers that need to replicate this record
int to_commit = num_servers / 2;
int to_commit = num_servers / 2;
std::map<int, unsigned int>::iterator it;
for (it = next.begin(); it != next.end() && to_commit > 0; ++it)
for (it = next.begin(); it != next.end() ; ++it)
{
int rindex = request->index();
@ -601,8 +601,8 @@ void RaftManager::replicate_log(ReplicaRequest * request)
{
to_commit--;
}
else if ( rindex == (int) it->second )
{
else if ( rindex == (int) it->second )
{
replica_manager.replicate(it->first);
}
}
@ -641,7 +641,7 @@ void RaftManager::replicate_success(int follower_id)
Nebula& nd = Nebula::instance();
LogDB * logdb = nd.get_logdb();
unsigned int db_lindex, db_lterm;
unsigned int db_lindex, db_lterm;
logdb->get_last_record_index(db_lindex, db_lterm);
@ -665,7 +665,7 @@ void RaftManager::replicate_success(int follower_id)
{
commit = replicated_index;
}
if (db_lindex > replicated_index && state == LEADER &&
requests.is_replicable(replicated_index + 1))
{

View File

@ -96,7 +96,12 @@ void ReplicaThread::do_replication()
if ( pthread_cond_timedwait(&cond, &mutex, &timeout) == ETIMEDOUT )
{
_pending_requests = retry_request;
if ( _prending_requests == true )
{
NebulaLog::log("RCM", Log::WARN, "Replication timeout with pending requests");
}
_pending_requests = retry_request || _pending_requests;
}
if ( _finalize )