From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id B1C856EC45; Thu, 12 Aug 2021 12:54:24 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B1C856EC45 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1628762064; bh=R9Wbrnm4Gvn6Mik13aOCR6Gxbcj7rUMRmk4Y2mMZ4fg=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=wmv5Z3hx0VvxxuAel6AxvBd5DTOsZ0z+2VhdqJKtiwuNQWFXuE8RH20dcWQeKuhHr lDc7z4XY5Hv45vjbHe368VZwNvTrZxZ5CyL0lTt/BrQEhu+67U8zZ2jambYeFsXL1E arppL3G/J2Jbcqa/jvklg0hY66r1l+fnUDpgvUHE= Received: from smtp33.i.mail.ru (smtp33.i.mail.ru [94.100.177.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 13B6F6EC45 for ; Thu, 12 Aug 2021 12:50:57 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 13B6F6EC45 Received: by smtp33.i.mail.ru with esmtpa (envelope-from ) id 1mE7MV-0005NV-Oc; Thu, 12 Aug 2021 12:50:56 +0300 To: tarantool-patches@dev.tarantool.org, vdavydov@tarantool.org, v.shpilevoy@tarantool.org Date: Thu, 12 Aug 2021 12:50:44 +0300 Message-Id: <1ead67d6dcd7f83fa9af43780972dcdf41195d0c.1628759886.git.mechanik20051988@tarantool.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD92087353F0EC44DD9BCE6B93DE0C6C3914462CDB1732D383C182A05F5380850404EC0CA9C85D9AA7CB04D9B96F0EADC0EBC3065D17CA9ADCA9B9E8DC7D7FAF790 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7180ADF26E81B0C77EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006379F6495389D012EA98638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D850A8A02E80DF13D66FAF598DFE3AD65B117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC2EE5AD8F952D28FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18C26CFBAC0749D213D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EEC8105B04EFE0762868E75A379BAF682BD8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE3E3786DD2C77EBDAA6136E347CC761E07C4224003CC836476EA7A3FFF5B025636E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637B7457ED07BBA7E3EEFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8183A4AFAF3EA6BDC44E1F4276B8099419669415AB31670C86C65AA460A34A793276B9401CADE8E06329C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EFA183FDCE24978B01699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D347D10A9FCB2A62DFE8FBE601A305334DA750371E636C50F243CBA40A076903D90444849F3EA66F7001D7E09C32AA3244CA8E181A246942CBC89E9BC77C87E5D29A8CE788DE6831205927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojKW4rnL99YhKG67J0cV6n9w== X-Mailru-Sender: 583F1D7ACE8F49BD29FC049B2A5BF96395EA2367FC8BA7F5B654172B2AE0DA94BC06D830CF680444B79567116EAC6FCF4E830D9205DBEA545646F0D3C63A617F27ACC94E9A535D22112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: [Tarantool-patches] [PATCH v4 7/9] iproto: add RAFT prefix for all requests related to 'raft'. X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: mechanik20051988 via Tarantool-patches Reply-To: mechanik20051988 Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 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