Commit 876f8d7c authored by Yossi Gottlieb's avatar Yossi Gottlieb
Browse files

Add raft_pop_entry().

This is required to allow append-only persistent log formats, where
raft_append_entry() is called but may be reverted later on.
parent c5de362a
...@@ -715,6 +715,13 @@ void raft_set_commit_idx(raft_server_t* me, raft_index_t commit_idx); ...@@ -715,6 +715,13 @@ void raft_set_commit_idx(raft_server_t* me, raft_index_t commit_idx);
* RAFT_ERR_NOMEM memory allocation failure */ * RAFT_ERR_NOMEM memory allocation failure */
int raft_append_entry(raft_server_t* me, raft_entry_t* ety); int raft_append_entry(raft_server_t* me, raft_entry_t* ety);
/** Remove the last entry from the server's log.
* This should only be used when reloading persistent state from an append log
* store, where removed entries are still in the log but followed by a pop
* action.
*/
int raft_pop_entry(raft_server_t* me);
/** Confirm if a msg_entry_response has been committed. /** Confirm if a msg_entry_response has been committed.
* @param[in] r The response we want to check */ * @param[in] r The response we want to check */
int raft_msg_entry_response_committed(raft_server_t* me_, int raft_msg_entry_response_committed(raft_server_t* me_,
......
...@@ -1193,6 +1193,13 @@ int raft_poll_entry(raft_server_t* me_, raft_entry_t **ety) ...@@ -1193,6 +1193,13 @@ int raft_poll_entry(raft_server_t* me_, raft_entry_t **ety)
return 0; return 0;
} }
int raft_pop_entry(raft_server_t* me_)
{
raft_server_private_t* me = (raft_server_private_t*)me_;
return log_delete(me->log, log_get_current_idx(me->log));
}
raft_index_t raft_get_first_entry_idx(raft_server_t* me_) raft_index_t raft_get_first_entry_idx(raft_server_t* me_)
{ {
raft_server_private_t* me = (raft_server_private_t*)me_; raft_server_private_t* me = (raft_server_private_t*)me_;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment