diff --git a/src/raft/RaftManager.cc b/src/raft/RaftManager.cc index 027fa1dc2c..2a667ac9fc 100644 --- a/src/raft/RaftManager.cc +++ b/src/raft/RaftManager.cc @@ -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::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)) { diff --git a/src/raft/ReplicaThread.cc b/src/raft/ReplicaThread.cc index c562e149e0..da84923a10 100644 --- a/src/raft/ReplicaThread.cc +++ b/src/raft/ReplicaThread.cc @@ -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 )