Tarantool development patches archive
 help / color / mirror / Atom feed
From: mechanik20051988 via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: tarantool-patches@dev.tarantool.org, vdavydov@tarantool.org,
	v.shpilevoy@tarantool.org
Subject: [Tarantool-patches] [PATCH v4 7/9] iproto: add RAFT prefix for all requests related to 'raft'.
Date: Thu, 12 Aug 2021 12:50:44 +0300	[thread overview]
Message-ID: <1ead67d6dcd7f83fa9af43780972dcdf41195d0c.1628759886.git.mechanik20051988@tarantool.org> (raw)
In-Reply-To: <cover.1628759886.git.mechanik20051988@tarantool.org>

Adding interactive transactions over iproto streamss requires
adding new request types for begin, commit and rollback them.
The type names of these new requests conflict with the existing
names for the 'raft' requests. Adding RAFT prefix for all requests
related to 'raft' resolves this problem.

Part of #5860

@TarantoolBot document
Title: add RAFT prefix for all requests related to 'raft'.
Rename IPROTO_PROMOTE, IPROTO_DEMOTE, IPROTO_CONFIRM and
IPROTO_ROLLBACK to IPROTO_RAFT_PROMOTE, IPROTO_RAFT_DEMOTE,
IPROTO_RAFT_CONFIRM and IPROTO_RAFT_ROLLBACK accordingly.
---
 src/box/box.cc             |  4 ++--
 src/box/iproto_constants.h | 22 +++++++++++-----------
 src/box/memtx_engine.c     |  4 ++--
 src/box/txn.c              |  2 +-
 src/box/txn_limbo.c        | 18 +++++++++---------
 src/box/xrow.h             |  4 ++--
 6 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/src/box/box.cc b/src/box/box.cc
index eb9baa4b8..ead02c58c 100644
--- a/src/box/box.cc
+++ b/src/box/box.cc
@@ -1669,7 +1669,7 @@ box_issue_promote(uint32_t prev_leader_id, int64_t promote_lsn)
 	txn_limbo_write_promote(&txn_limbo, promote_lsn,
 				raft->term);
 	struct synchro_request req = {
-		.type = IPROTO_PROMOTE,
+		.type = IPROTO_RAFT_PROMOTE,
 		.replica_id = prev_leader_id,
 		.origin_id = instance_id,
 		.lsn = promote_lsn,
@@ -1691,7 +1691,7 @@ box_issue_demote(uint32_t prev_leader_id, int64_t promote_lsn)
 	txn_limbo_write_demote(&txn_limbo, promote_lsn,
 				box_raft()->term);
 	struct synchro_request req = {
-		.type = IPROTO_DEMOTE,
+		.type = IPROTO_RAFT_DEMOTE,
 		.replica_id = prev_leader_id,
 		.origin_id = instance_id,
 		.lsn = promote_lsn,
diff --git a/src/box/iproto_constants.h b/src/box/iproto_constants.h
index b9498868c..8792737b2 100644
--- a/src/box/iproto_constants.h
+++ b/src/box/iproto_constants.h
@@ -242,14 +242,14 @@ enum iproto_type {
 
 	IPROTO_RAFT = 30,
 	/** PROMOTE request. */
-	IPROTO_PROMOTE = 31,
+	IPROTO_RAFT_PROMOTE = 31,
 	/** DEMOTE request. */
-	IPROTO_DEMOTE = 32,
+	IPROTO_RAFT_DEMOTE = 32,
 
 	/** A confirmation message for synchronous transactions. */
-	IPROTO_CONFIRM = 40,
+	IPROTO_RAFT_CONFIRM = 40,
 	/** A rollback message for synchronous transactions. */
-	IPROTO_ROLLBACK = 41,
+	IPROTO_RAFT_ROLLBACK = 41,
 
 	/** PING request */
 	IPROTO_PING = 64,
@@ -314,13 +314,13 @@ iproto_type_name(uint16_t type)
 	switch (type) {
 	case IPROTO_RAFT:
 		return "RAFT";
-	case IPROTO_PROMOTE:
+	case IPROTO_RAFT_PROMOTE:
 		return "PROMOTE";
-	case IPROTO_DEMOTE:
+	case IPROTO_RAFT_DEMOTE:
 		return "DEMOTE";
-	case IPROTO_CONFIRM:
+	case IPROTO_RAFT_CONFIRM:
 		return "CONFIRM";
-	case IPROTO_ROLLBACK:
+	case IPROTO_RAFT_ROLLBACK:
 		return "ROLLBACK";
 	case VY_INDEX_RUN_INFO:
 		return "RUNINFO";
@@ -371,15 +371,15 @@ dml_request_key_map(uint16_t type)
 static inline bool
 iproto_type_is_synchro_request(uint16_t type)
 {
-	return type == IPROTO_CONFIRM || type == IPROTO_ROLLBACK ||
-	       type == IPROTO_PROMOTE || type == IPROTO_DEMOTE;
+	return type == IPROTO_RAFT_CONFIRM || type == IPROTO_RAFT_ROLLBACK ||
+	       type == IPROTO_RAFT_PROMOTE || type == IPROTO_RAFT_DEMOTE;
 }
 
 /** PROMOTE/DEMOTE entry (synchronous replication and leader elections). */
 static inline bool
 iproto_type_is_promote_request(uint32_t type)
 {
-       return type == IPROTO_PROMOTE || type == IPROTO_DEMOTE;
+       return type == IPROTO_RAFT_PROMOTE || type == IPROTO_RAFT_DEMOTE;
 }
 
 static inline bool
diff --git a/src/box/memtx_engine.c b/src/box/memtx_engine.c
index 0b06e5e63..fc369149d 100644
--- a/src/box/memtx_engine.c
+++ b/src/box/memtx_engine.c
@@ -229,7 +229,7 @@ memtx_engine_recover_raft(const struct xrow_header *row)
 static int
 memtx_engine_recover_synchro(const struct xrow_header *row)
 {
-	assert(row->type == IPROTO_PROMOTE);
+	assert(row->type == IPROTO_RAFT_PROMOTE);
 	struct synchro_request req;
 	if (xrow_decode_synchro(row, &req) != 0)
 		return -1;
@@ -250,7 +250,7 @@ memtx_engine_recover_snapshot_row(struct memtx_engine *memtx,
 	if (row->type != IPROTO_INSERT) {
 		if (row->type == IPROTO_RAFT)
 			return memtx_engine_recover_raft(row);
-		if (row->type == IPROTO_PROMOTE)
+		if (row->type == IPROTO_RAFT_PROMOTE)
 			return memtx_engine_recover_synchro(row);
 		diag_set(ClientError, ER_UNKNOWN_REQUEST_TYPE,
 			 (uint32_t) row->type);
diff --git a/src/box/txn.c b/src/box/txn.c
index b80e722a4..e057d2762 100644
--- a/src/box/txn.c
+++ b/src/box/txn.c
@@ -407,7 +407,7 @@ txn_commit_stmt(struct txn *txn, struct request *request)
 	/*
 	 * Create WAL record for the write requests in
 	 * non-temporary spaces. stmt->space can be NULL for
-	 * IRPOTO_NOP or IPROTO_CONFIRM.
+	 * IRPOTO_NOP or IPROTO_RAFT_CONFIRM.
 	 */
 	if (stmt->space == NULL || !space_is_temporary(stmt->space)) {
 		if (txn_add_redo(txn, stmt, request) != 0)
diff --git a/src/box/txn_limbo.c b/src/box/txn_limbo.c
index 570f77c46..70447caaf 100644
--- a/src/box/txn_limbo.c
+++ b/src/box/txn_limbo.c
@@ -305,7 +305,7 @@ void
 txn_limbo_checkpoint(const struct txn_limbo *limbo,
 		     struct synchro_request *req)
 {
-	req->type = IPROTO_PROMOTE;
+	req->type = IPROTO_RAFT_PROMOTE;
 	req->replica_id = limbo->owner_id;
 	req->lsn = limbo->confirmed_lsn;
 	req->term = limbo->promote_greatest_term;
@@ -372,7 +372,7 @@ txn_limbo_write_confirm(struct txn_limbo *limbo, int64_t lsn)
 	assert(lsn > limbo->confirmed_lsn);
 	assert(!limbo->is_in_rollback);
 	limbo->confirmed_lsn = lsn;
-	txn_limbo_write_synchro(limbo, IPROTO_CONFIRM, lsn, 0);
+	txn_limbo_write_synchro(limbo, IPROTO_RAFT_CONFIRM, lsn, 0);
 }
 
 /** Confirm all the entries <= @a lsn. */
@@ -450,7 +450,7 @@ txn_limbo_write_rollback(struct txn_limbo *limbo, int64_t lsn)
 	assert(lsn > limbo->confirmed_lsn);
 	assert(!limbo->is_in_rollback);
 	limbo->is_in_rollback = true;
-	txn_limbo_write_synchro(limbo, IPROTO_ROLLBACK, lsn, 0);
+	txn_limbo_write_synchro(limbo, IPROTO_RAFT_ROLLBACK, lsn, 0);
 	limbo->is_in_rollback = false;
 }
 
@@ -498,7 +498,7 @@ txn_limbo_write_promote(struct txn_limbo *limbo, int64_t lsn, uint64_t term)
 	struct txn_limbo_entry *e = txn_limbo_last_synchro_entry(limbo);
 	assert(e == NULL || e->lsn <= lsn);
 	(void) e;
-	txn_limbo_write_synchro(limbo, IPROTO_PROMOTE, lsn, term);
+	txn_limbo_write_synchro(limbo, IPROTO_RAFT_PROMOTE, lsn, term);
 	limbo->is_in_rollback = false;
 }
 
@@ -526,7 +526,7 @@ txn_limbo_write_demote(struct txn_limbo *limbo, int64_t lsn, uint64_t term)
 	struct txn_limbo_entry *e = txn_limbo_last_synchro_entry(limbo);
 	assert(e == NULL || e->lsn <= lsn);
 	(void)e;
-	txn_limbo_write_synchro(limbo, IPROTO_DEMOTE, lsn, term);
+	txn_limbo_write_synchro(limbo, IPROTO_RAFT_DEMOTE, lsn, term);
 	limbo->is_in_rollback = false;
 }
 
@@ -768,16 +768,16 @@ txn_limbo_process(struct txn_limbo *limbo, const struct synchro_request *req)
 		lsn = 0;
 	}
 	switch (req->type) {
-	case IPROTO_CONFIRM:
+	case IPROTO_RAFT_CONFIRM:
 		txn_limbo_read_confirm(limbo, lsn);
 		break;
-	case IPROTO_ROLLBACK:
+	case IPROTO_RAFT_ROLLBACK:
 		txn_limbo_read_rollback(limbo, lsn);
 		break;
-	case IPROTO_PROMOTE:
+	case IPROTO_RAFT_PROMOTE:
 		txn_limbo_read_promote(limbo, req->origin_id, lsn);
 		break;
-	case IPROTO_DEMOTE:
+	case IPROTO_RAFT_DEMOTE:
 		txn_limbo_read_demote(limbo, lsn);
 		break;
 	default:
diff --git a/src/box/xrow.h b/src/box/xrow.h
index cb83fddff..d32dcbc0d 100644
--- a/src/box/xrow.h
+++ b/src/box/xrow.h
@@ -233,8 +233,8 @@ xrow_encode_dml(const struct request *request, struct region *region,
  */
 struct synchro_request {
 	/**
-	 * Operation type - either IPROTO_ROLLBACK or IPROTO_CONFIRM or
-	 * IPROTO_PROMOTE
+	 * Operation type - either IPROTO_RAFT_ROLLBACK or IPROTO_RAFT_CONFIRM
+	 * or IPROTO_RAFT_PROMOTE
 	 */
 	uint16_t type;
 	/**
-- 
2.20.1


  parent reply	other threads:[~2021-08-12  9:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-12  9:50 [Tarantool-patches] [PATCH v4 0/9] implement iproto streams mechanik20051988 via Tarantool-patches
2021-08-12  9:50 ` [Tarantool-patches] [PATCH v4 1/9] xrow: remove unused call_request::header mechanik20051988 via Tarantool-patches
2021-08-12  9:50 ` [Tarantool-patches] [PATCH v4 2/9] iproto: clear request::header for client requests mechanik20051988 via Tarantool-patches
2021-08-12  9:50 ` [Tarantool-patches] [PATCH v4 3/9] iproto: implement stream id in binary iproto protocol mechanik20051988 via Tarantool-patches
2021-08-12  9:50 ` [Tarantool-patches] [PATCH v4 4/9] salad: fix segfault in case when mhash table allocation failure mechanik20051988 via Tarantool-patches
2021-08-12  9:50 ` [Tarantool-patches] [PATCH v4 5/9] iproto: implement streams in iproto mechanik20051988 via Tarantool-patches
2021-08-12  9:50 ` [Tarantool-patches] [PATCH v4 6/9] net.box: add stream support to net.box mechanik20051988 via Tarantool-patches
2021-08-12 17:49   ` Vladislav Shpilevoy via Tarantool-patches
2021-08-12  9:50 ` mechanik20051988 via Tarantool-patches [this message]
2021-08-12  9:50 ` [Tarantool-patches] [PATCH v4 8/9] iproto: implement interactive transactions over iproto streams mechanik20051988 via Tarantool-patches
2021-08-12 10:48   ` Vladimir Davydov via Tarantool-patches
2021-08-12  9:50 ` [Tarantool-patches] [PATCH v4 9/9] net.box: add interactive transaction support in net.box mechanik20051988 via Tarantool-patches
2021-08-12 17:52   ` Vladislav Shpilevoy via Tarantool-patches
2021-08-13  7:44     ` Vladimir Davydov via Tarantool-patches
2021-08-12 10:51 ` [Tarantool-patches] [PATCH v4 0/9] implement iproto streams Vladimir Davydov via Tarantool-patches

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=1ead67d6dcd7f83fa9af43780972dcdf41195d0c.1628759886.git.mechanik20051988@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=mechanik20051988@tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --cc=vdavydov@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v4 7/9] iproto: add RAFT prefix for all requests related to '\''raft'\''.' \
    /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