[Tarantool-patches] [RAFT 08/10] [tosquash] raft: rename raft_process to raft_process_recovery
Serge Petrenko
sergepetrenko at tarantool.org
Wed Aug 26 10:52:40 MSK 2020
From: Vladislav Shpilevoy <v.shpilevoy at tarantool.org>
There is another 'process' for remote messages from other raft
nodes. In order to make these functions more clearly separated,
the old function used for local state recovery is renamed to
raft_process_recovery.
This should be squashed into the first commit about persistent
raft state.
---
src/box/box.cc | 2 +-
src/box/memtx_engine.c | 2 +-
src/box/raft.c | 14 +++++++++++++-
src/box/raft.h | 2 +-
4 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/src/box/box.cc b/src/box/box.cc
index e7eb79e9f..d01de2519 100644
--- a/src/box/box.cc
+++ b/src/box/box.cc
@@ -380,7 +380,7 @@ apply_wal_row(struct xstream *stream, struct xrow_header *row)
/* Vclock is never persisted in WAL by Raft. */
if (xrow_decode_raft(row, &raft_req, NULL) != 0)
diag_raise();
- raft_process(&raft_req);
+ raft_process_recovery(&raft_req);
return;
}
xrow_decode_dml_xc(row, &request, dml_request_key_map(row->type));
diff --git a/src/box/memtx_engine.c b/src/box/memtx_engine.c
index 7de12a569..b0b744db8 100644
--- a/src/box/memtx_engine.c
+++ b/src/box/memtx_engine.c
@@ -209,7 +209,7 @@ memtx_engine_recover_raft(const struct xrow_header *row)
/* Vclock is never persisted in WAL by Raft. */
if (xrow_decode_raft(row, &req, NULL) != 0)
return -1;
- raft_process(&req);
+ raft_process_recovery(&req);
return 0;
}
diff --git a/src/box/raft.c b/src/box/raft.c
index 714a1518a..34c1cf7aa 100644
--- a/src/box/raft.c
+++ b/src/box/raft.c
@@ -45,12 +45,24 @@ struct raft raft = {
};
void
-raft_process(const struct raft_request *req)
+raft_process_recovery(const struct raft_request *req)
{
if (req->term != 0)
raft.term = req->term;
if (req->vote != 0)
raft.vote = req->vote;
+ /*
+ * Role is never persisted. If recovery is happening, the
+ * node was restarted, and the former role can be false
+ * anyway.
+ */
+ assert(req->state == RAFT_STATE_NONE);
+ /*
+ * Vclock is always persisted by some other subsystem - WAL, snapshot.
+ * It is used only to decide to whom to give the vote during election,
+ * as a part of the volatile state.
+ */
+ assert(req->vclock == NULL);
}
void
diff --git a/src/box/raft.h b/src/box/raft.h
index 927aa8f5f..be071c215 100644
--- a/src/box/raft.h
+++ b/src/box/raft.h
@@ -65,7 +65,7 @@ raft_vote(uint32_t vote_for);
/** Process a raft entry stored in WAL/snapshot. */
void
-raft_process(const struct raft_request *req);
+raft_process_recovery(const struct raft_request *req);
/** Process a raft status message coming from the network. */
void
--
2.20.1 (Apple Git-117)
More information about the Tarantool-patches
mailing list