diff --git a/include/ReplicaRequest.h b/include/ReplicaRequest.h index 497031ecf5..d337b230ab 100644 --- a/include/ReplicaRequest.h +++ b/include/ReplicaRequest.h @@ -195,6 +195,24 @@ public: pthread_mutex_unlock(&mutex); } + /** + * Remove a replication request associated to this index + * @param rindex of the request + */ + void remove(int rindex) + { + pthread_mutex_lock(&mutex); + + std::map::iterator it = requests.find(rindex); + + if ( it != requests.end() ) + { + requests.erase(it); + } + + pthread_mutex_unlock(&mutex); + } + /** * Notify all writers and clear the replica map */ diff --git a/src/raft/RaftManager.cc b/src/raft/RaftManager.cc index 8cbacfa314..c21ad86449 100644 --- a/src/raft/RaftManager.cc +++ b/src/raft/RaftManager.cc @@ -582,6 +582,8 @@ void RaftManager::replicate_log(ReplicaRequest * request) { request->notify(); + requests.remove(request->index()); + pthread_mutex_unlock(&mutex); return; } @@ -594,6 +596,8 @@ void RaftManager::replicate_log(ReplicaRequest * request) request->timeout = false; commit = request->index(); + + requests.remove(request->index()); } else {