[Tarantool-patches] [PATCH v2 9/8] replication: send current Raft term in join response
Serge Petrenko
sergepetrenko at tarantool.org
Mon Jun 21 15:11:25 MSK 2021
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);
More information about the Tarantool-patches
mailing list