Tarantool development patches archive
 help / color / mirror / Atom feed
From: Serge Petrenko via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: v.shpilevoy@tarantool.org, gorcunov@gmail.com
Cc: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH v2 9/8] replication: send current Raft term in join response
Date: Mon, 21 Jun 2021 15:11:25 +0300	[thread overview]
Message-ID: <039adbec-220f-6606-0568-ba44f4a13e0d@tarantool.org> (raw)
In-Reply-To: <cover.1623963649.git.sergepetrenko@tarantool.org>

Make Raft nodes send out their latest persisted term to joining
replicas.

Follow-up #6034

diff --git a/src/box/applier.cc b/src/box/applier.cc
index 9d90a2384..2b3c653a5 100644
--- a/src/box/applier.cc
+++ b/src/box/applier.cc
@@ -463,6 +463,11 @@ applier_wait_snapshot(struct applier *applier)
                         if (xrow_decode_synchro(&row, &req) != 0)
                                 diag_raise();
                         txn_limbo_process(&txn_limbo, &req);
+               } else if (iproto_type_is_raft_request(row.type)) {
+                       struct raft_request req;
+                       if (xrow_decode_raft(&row, &req, NULL) != 0)
+                               diag_raise();
+                       box_raft_recover(&req);
                 } else if (iproto_type_is_error(row.type)) {
                         xrow_decode_error_xc(&row);  /* rethrow error */
                 } else {
diff --git a/src/box/relay.cc b/src/box/relay.cc
index e05b53d5d..510e5c420 100644
--- a/src/box/relay.cc
+++ b/src/box/relay.cc
@@ -400,7 +400,9 @@ relay_initial_join(int fd, uint64_t sync, struct 
vclock *vclock)
                 diag_raise();

         struct synchro_request req;
+       struct raft_request raft_req;
         txn_limbo_checkpoint(&txn_limbo, &req);
+       box_raft_checkpoint_local(&raft_req);

         /* Respond to the JOIN request with the current vclock. */
         struct xrow_header row;
@@ -419,6 +421,11 @@ relay_initial_join(int fd, uint64_t sync, struct 
vclock *vclock)
                 row.sync = sync;
                 coio_write_xrow(&relay->io, &row);
         }
+       if (raft_req.term > 1) {
+               xrow_encode_raft(&row, &fiber()->gc, &raft_req);
+               row.sync = sync;
+               coio_write_xrow(&relay->io, &row);
+       }

         /* Send read view to the replica. */
         engine_join_xc(&ctx, &relay->stream);

      parent reply	other threads:[~2021-06-21 12:11 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-17 21:07 [Tarantool-patches] [PATCH v2 0/8] forbid implicit limbo ownership transition Serge Petrenko via Tarantool-patches
2021-06-17 21:07 ` [Tarantool-patches] [PATCH v2 1/8] replication: always send raft state to subscribers Serge Petrenko via Tarantool-patches
2021-06-17 21:07 ` [Tarantool-patches] [PATCH v2 2/8] txn_limbo: fix promote term filtering Serge Petrenko via Tarantool-patches
2021-06-17 22:05   ` Cyrill Gorcunov via Tarantool-patches
2021-06-18  8:55     ` Serge Petrenko via Tarantool-patches
2021-06-18 10:31   ` Cyrill Gorcunov via Tarantool-patches
2021-06-21 15:09     ` Serge Petrenko via Tarantool-patches
2021-06-17 21:07 ` [Tarantool-patches] [PATCH v2 3/8] raft: refactor raft_new_term() Serge Petrenko via Tarantool-patches
2021-06-17 21:07 ` [Tarantool-patches] [PATCH v2 4/8] box: make promote always bump the term Serge Petrenko via Tarantool-patches
2021-06-17 21:07 ` [Tarantool-patches] [PATCH v2 5/8] replication: forbid implicit limbo owner transition Serge Petrenko via Tarantool-patches
2021-06-17 21:07 ` [Tarantool-patches] [PATCH v2 6/8] box: introduce `box.ctl.demote` Serge Petrenko via Tarantool-patches
2021-06-17 21:15   ` Serge Petrenko via Tarantool-patches
2021-06-17 21:07 ` [Tarantool-patches] [PATCH v2 7/8] txn_limbo: persist the latest effective promote in snapshot Serge Petrenko via Tarantool-patches
2021-06-17 21:07 ` [Tarantool-patches] [PATCH v2 8/8] replication: send latest effective promote in initial join Serge Petrenko via Tarantool-patches
2021-06-18 13:02 ` [Tarantool-patches] [PATCH v2 0/8] forbid implicit limbo ownership transition Cyrill Gorcunov via Tarantool-patches
2021-06-21 12:11 ` Serge Petrenko via Tarantool-patches [this message]

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=039adbec-220f-6606-0568-ba44f4a13e0d@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=gorcunov@gmail.com \
    --cc=sergepetrenko@tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v2 9/8] replication: send current Raft term in join response' \
    /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