From: Serge Petrenko <sergepetrenko@tarantool.org> To: v.shpilevoy@tarantool.org, gorcunov@gmail.com, sergos@tarantool.org Cc: tarantool-patches@dev.tarantool.org Subject: [Tarantool-patches] [RAFT 08/10] [tosquash] raft: rename raft_process to raft_process_recovery Date: Wed, 26 Aug 2020 10:52:40 +0300 [thread overview] Message-ID: <f7882f85ea943e3ba02c5f09f3d5b8c622a1818c.1598427905.git.sergepetrenko@tarantool.org> (raw) In-Reply-To: <cover.1598427905.git.sergepetrenko@tarantool.org> From: Vladislav Shpilevoy <v.shpilevoy@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)
next prev parent reply other threads:[~2020-08-26 7:53 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-08-26 7:52 [Tarantool-patches] [RAFT 00/10] raft implementation Serge Petrenko 2020-08-26 7:52 ` [Tarantool-patches] [RAFT 01/10] raft: introduce persistent raft state Serge Petrenko 2020-08-26 7:52 ` [Tarantool-patches] [RAFT 02/10] raft: relay status updates to followers Serge Petrenko 2020-08-27 20:36 ` Vladislav Shpilevoy 2020-08-28 10:10 ` Sergey Petrenko 2020-08-26 7:52 ` [Tarantool-patches] [RAFT 03/10] [tosquash] raft: return raft_request to xrow Serge Petrenko 2020-08-26 7:52 ` [Tarantool-patches] [RAFT 04/10] [tosquash] raft: introduce IPROTO_RAFT_VCLOCK Serge Petrenko 2020-08-26 7:52 ` [Tarantool-patches] [RAFT 05/10] [tosquash] xrow: refactor raft request codec Serge Petrenko 2020-08-26 7:52 ` [Tarantool-patches] [RAFT 06/10] [tosquash] raft: don't fill raft_request manually Serge Petrenko 2020-08-26 7:52 ` [Tarantool-patches] [RAFT 07/10] [tosquash] raft: rename curr_leader to leader Serge Petrenko 2020-08-26 7:52 ` Serge Petrenko [this message] 2020-08-26 7:52 ` [Tarantool-patches] [RAFT 09/10] [tosquash] applier: handler error at raft row appliance Serge Petrenko 2020-08-26 7:53 ` [Tarantool-patches] [RAFT 10/10] [tosquash] relay: move raft broadcast details into relay Serge Petrenko
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=f7882f85ea943e3ba02c5f09f3d5b8c622a1818c.1598427905.git.sergepetrenko@tarantool.org \ --to=sergepetrenko@tarantool.org \ --cc=gorcunov@gmail.com \ --cc=sergos@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [RAFT 08/10] [tosquash] raft: rename raft_process to raft_process_recovery' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox