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 B49556EC56; Wed, 14 Jul 2021 21:27:53 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B49556EC56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1626287273; bh=5A90jSXq7yFCojnp6WN8pOqlNDmAjVxvXFa7kjSXDy0=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=paFXWNkpj7IcMRnKqHVFSXoOLzTH6mmwaFLZnIuhlOmPSwGoioDDm6c4ahfQTfwD3 Nd3J/nS87do2ja1V+K6qEY/JT059uCappgHqlc0Wt54VeFLqHKonMwTgfTJ1gTSuUS bcniOSriBHoKSEgBqtSHHybgfAgBFPYqwtEva5Dk= Received: from smtp58.i.mail.ru (smtp58.i.mail.ru [217.69.128.38]) (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 C79A36EC5C for ; Wed, 14 Jul 2021 21:26:00 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C79A36EC5C Received: by smtp58.i.mail.ru with esmtpa (envelope-from ) id 1m3ja3-0007Q7-Pe; Wed, 14 Jul 2021 21:26:00 +0300 To: v.shpilevoy@tarantool.org, gorcunov@gmail.com Date: Wed, 14 Jul 2021 21:25:32 +0300 Message-Id: <9c8397edc54ba5ce2ba30792adcabb003fae3aee.1626287002.git.sergepetrenko@tarantool.org> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-4EC0790: 10 X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD97BB0EF39AD2B33D5A52DC40C1D324F80A71B59DA57F828EE182A05F538085040C7DCF4898E1B6C83CCE645D46B21A24C8C96DA8CFF0505578286A0892F7B41DC X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7E9F9EA069697529EEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637E0FC02D497BF09508638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8063E4C71243BFD65284A661E71CA3C4F117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCF1175FABE1C0F9B6A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18F04B652EEC242312D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6D635BA3ABDB36C18089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CE68746B1F2AB10C69AB83263A0FF8B6C87375ED40DF102059C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EF309DFB797F6729CB699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D341ADA1A41A420E9B224DCF7836AD5075A0A041BC19A95D81E5645D8C3142DDCB4B9E829E9402DAE791D7E09C32AA3244C8591B6D7B29529D0B364525ADC56F37BA995755A1445935E927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojDdSFIg49M1Rr661AvGsiog== X-Mailru-Sender: 3B9A0136629DC9125D61937A2360A446DCF67A6ACA5D040D157B51FC0CFB7078976AF1CB91E6EC81424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: [Tarantool-patches] [PATCH v4 04/16] replication: encode version in JOIN request 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: Serge Petrenko via Tarantool-patches Reply-To: Serge Petrenko Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" The replica's version will be needed once sending limbo and election state snapshot is implemented. Prerequisite #6034 @TarantoolBot document Title: New field in JOIN request JOIN request now comes with a new field: replica's version. The field uses IPROTO_SERVER_VERSION key. --- src/box/box.cc | 7 +++++-- src/box/xrow.c | 4 +++- src/box/xrow.h | 25 +++++++++++++++---------- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/box/box.cc b/src/box/box.cc index 5dcf5b460..6d5516682 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -2495,7 +2495,9 @@ box_process_register(struct ev_io *io, struct xrow_header *header) struct tt_uuid instance_uuid = uuid_nil; struct vclock replica_vclock; - xrow_decode_register_xc(header, &instance_uuid, &replica_vclock); + uint32_t replica_version_id; + xrow_decode_register_xc(header, &instance_uuid, &replica_vclock, + &replica_version_id); if (!is_box_configured) tnt_raise(ClientError, ER_LOADING); @@ -2620,7 +2622,8 @@ box_process_join(struct ev_io *io, struct xrow_header *header) /* Decode JOIN request */ struct tt_uuid instance_uuid = uuid_nil; - xrow_decode_join_xc(header, &instance_uuid); + uint32_t replica_version_id; + xrow_decode_join_xc(header, &instance_uuid, &replica_version_id); /* Check that bootstrap has been finished */ if (!is_box_configured) diff --git a/src/box/xrow.c b/src/box/xrow.c index 16cb2484c..400e0456f 100644 --- a/src/box/xrow.c +++ b/src/box/xrow.c @@ -1639,10 +1639,12 @@ xrow_encode_join(struct xrow_header *row, const struct tt_uuid *instance_uuid) return -1; } char *data = buf; - data = mp_encode_map(data, 1); + data = mp_encode_map(data, 2); data = mp_encode_uint(data, IPROTO_INSTANCE_UUID); /* Greet the remote replica with our replica UUID */ data = xrow_encode_uuid(data, instance_uuid); + data = mp_encode_uint(data, IPROTO_SERVER_VERSION); + data = mp_encode_uint(data, tarantool_version_id()); assert(data <= buf + size); row->body[0].iov_base = buf; diff --git a/src/box/xrow.h b/src/box/xrow.h index 9f61bfd47..6b06db5c1 100644 --- a/src/box/xrow.h +++ b/src/box/xrow.h @@ -471,15 +471,17 @@ xrow_encode_join(struct xrow_header *row, const struct tt_uuid *instance_uuid); * Decode JOIN command. * @param row Row to decode. * @param[out] instance_uuid. + * @param[out] version_id. * * @retval 0 Success. * @retval -1 Memory or format error. */ static inline int -xrow_decode_join(struct xrow_header *row, struct tt_uuid *instance_uuid) +xrow_decode_join(struct xrow_header *row, struct tt_uuid *instance_uuid, + uint32_t *version_id) { - return xrow_decode_subscribe(row, NULL, instance_uuid, NULL, NULL, NULL, - NULL); + return xrow_decode_subscribe(row, NULL, instance_uuid, NULL, version_id, + NULL, NULL); } /** @@ -487,15 +489,17 @@ xrow_decode_join(struct xrow_header *row, struct tt_uuid *instance_uuid) * @param row Row to decode. * @param[out] instance_uuid Instance uuid. * @param[out] vclock Instance vclock. + * @param[out] version_id Replica version id. + * * @retval 0 Success. * @retval -1 Memory or format error. */ static inline int xrow_decode_register(struct xrow_header *row, struct tt_uuid *instance_uuid, - struct vclock *vclock) + struct vclock *vclock, uint32_t *version_id) { - return xrow_decode_subscribe(row, NULL, instance_uuid, vclock, NULL, - NULL, NULL); + return xrow_decode_subscribe(row, NULL, instance_uuid, vclock, + version_id, NULL, NULL); } /** @@ -960,18 +964,19 @@ xrow_encode_join_xc(struct xrow_header *row, /** @copydoc xrow_decode_join. */ static inline void -xrow_decode_join_xc(struct xrow_header *row, struct tt_uuid *instance_uuid) +xrow_decode_join_xc(struct xrow_header *row, struct tt_uuid *instance_uuid, + uint32_t *version_id) { - if (xrow_decode_join(row, instance_uuid) != 0) + if (xrow_decode_join(row, instance_uuid, version_id) != 0) diag_raise(); } /** @copydoc xrow_decode_register. */ static inline void xrow_decode_register_xc(struct xrow_header *row, struct tt_uuid *instance_uuid, - struct vclock *vclock) + struct vclock *vclock, uint32_t *version_id) { - if (xrow_decode_register(row, instance_uuid, vclock) != 0) + if (xrow_decode_register(row, instance_uuid, vclock, version_id) != 0) diag_raise(); } -- 2.30.1 (Apple Git-130)