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 3744571212; Thu, 5 Aug 2021 21:18:19 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 3744571212 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1628187499; bh=AUmlDfb3+TWEOow1GWkAnHeO1ukSLCA+tTpQsfcKT1Y=; h=To:Cc:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=Dy+S/6Pz3gxsCkK9lwSaAoORyUzTTRNFRTJsbScNhtSJsLOXRUyJC6DE0YbqvPRrW ox/Vp4fpNS4ttqS7rSKMR/savCNw4ceGI7OfBYd7ew9LTIHqaH6eeFqTJQKUw9iYN/ a/CS93K1P6goOB5+HvUPGdb5aot8Xf1tECT6fxlU= Received: from smtp53.i.mail.ru (smtp53.i.mail.ru [94.100.177.113]) (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 9078F71212 for ; Thu, 5 Aug 2021 21:17:50 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 9078F71212 Received: by smtp53.i.mail.ru with esmtpa (envelope-from ) id 1mBhwD-0005CS-8f; Thu, 05 Aug 2021 21:17:49 +0300 To: v.shpilevoy@tarantool.org, vdavydov@tarantool.org Cc: tarantool-patches@dev.tarantool.org, mechanik20051988 Date: Thu, 5 Aug 2021 21:17:39 +0300 Message-Id: <7f1a921ef966fa619fb8bf1bda9f94d7f9c06c10.1628184138.git.mechanik20.05.1988@gmail.com> 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: 4F1203BC0FB41BD92087353F0EC44DD9D5AC6413C25DCF08E2C99C00A2DD9947182A05F538085040D7EF66EBB690B06DC8C1E83952D984E0B0429C3C85679C91B9836C9F5082A85A X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7CC84CC3AD347B910EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637C8CBD5573EAF738DEA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38BBCA57AF85F7723F2A6978325382BD9C17FB5946E079FB856CC7F00164DA146DAFE8445B8C89999728AA50765F790063793270F7220657A0A389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC8D2DCF9CF1F528DBCF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA73AA81AA40904B5D9A18204E546F3947C98A01D7C647FC0B36136E347CC761E074AD6D5ED66289B52698AB9A7B718F8C46E0066C2D8992A16725E5C173C3A84C38BD8D02BBC31AAF5BA3038C0950A5D36B5C8C57E37DE458B0BC6067A898B09E46D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE7DF8CE6DC69AA8536731C566533BA786AA5CC5B56E945C8DA X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8183A4AFAF3EA6BDC44C234C8B12C006B7A4A556CA68DC7B180C30EFF46127C1FC478484E53D9567523B1881A6453793CE9C32612AADDFBE061C61BE10805914D3804EBA3D8E7E5B87ABF8C51168CD8EBDB00E8CE3DD197987DDC48ACC2A39D04F89CDFB48F4795C241BDAD6C7F3747799A X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3435B1F14A93C4073FDC363E171AAF04D98E2AD511C76E837A30C0D551CD2FB34EA46FBB46EB5649EF1D7E09C32AA3244C856CCD836DC01B22A6F40FB68234C7A41DD47778AE04E04D927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojh4v93/7HD3VWrvcZ57soEw== X-Mailru-Sender: 583F1D7ACE8F49BD29FC049B2A5BF963272C3B768E89E9F113B0564DF997F6819FE81E2139D4DDD1B79567116EAC6FCF4E830D9205DBEA545646F0D3C63A617F27ACC94E9A535D22112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: [Tarantool-patches] [PATCH 1/7] iproto: implement stream id in binary iproto protocol 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" From: mechanik20051988 For further implementation of streams, we need to separate requests belonging to and not belonging to streams. For this purpose, the stream ID field was added to the iproto binary protocol. For requests that do not belong to stream, this field is omitted or equal to zero. For requests belonging to stream, we use this field to determine which stream the request belongs to. Part of #5860 @TarantoolBot document Title: new field in binary iproto protocol Add new field to binary iproto protocol. `IPROTO_STREAM_ID 0x0a` determines whether a request belongs to a stream or not. If this field is omited or equal to zero this request doesn't belongs to stream. --- src/box/iproto_constants.c | 4 +- src/box/iproto_constants.h | 1 + src/box/xrow.c | 8 ++ src/box/xrow.h | 5 ++ test/unit/xrow.cc | 7 +- test/unit/xrow.result | 168 +++++++++++++++++++------------------ 6 files changed, 109 insertions(+), 84 deletions(-) diff --git a/src/box/iproto_constants.c b/src/box/iproto_constants.c index addda39dc..f2902946a 100644 --- a/src/box/iproto_constants.c +++ b/src/box/iproto_constants.c @@ -43,10 +43,10 @@ const unsigned char iproto_key_type[IPROTO_KEY_MAX] = /* 0x07 */ MP_UINT, /* IPROTO_GROUP_ID */ /* 0x08 */ MP_UINT, /* IPROTO_TSN */ /* 0x09 */ MP_UINT, /* IPROTO_FLAGS */ + /* 0x0a */ MP_UINT, /* IPROTO_STREAM_ID */ /* }}} */ /* {{{ unused */ - /* 0x0a */ MP_UINT, /* 0x0b */ MP_UINT, /* 0x0c */ MP_UINT, /* 0x0d */ MP_UINT, @@ -198,7 +198,7 @@ const char *iproto_key_strs[IPROTO_KEY_MAX] = { "group id", /* 0x07 */ "tsn", /* 0x08 */ "flags", /* 0x09 */ - NULL, /* 0x0a */ + "stream_id", /* 0x0a */ NULL, /* 0x0b */ NULL, /* 0x0c */ NULL, /* 0x0d */ diff --git a/src/box/iproto_constants.h b/src/box/iproto_constants.h index ea7290da6..59e8574f3 100644 --- a/src/box/iproto_constants.h +++ b/src/box/iproto_constants.h @@ -72,6 +72,7 @@ enum iproto_key { IPROTO_GROUP_ID = 0x07, IPROTO_TSN = 0x08, IPROTO_FLAGS = 0x09, + IPROTO_STREAM_ID = 0x0a, /* Leave a gap for other keys in the header. */ IPROTO_SPACE_ID = 0x10, IPROTO_INDEX_ID = 0x11, diff --git a/src/box/xrow.c b/src/box/xrow.c index e5d9d5be5..44a75616a 100644 --- a/src/box/xrow.c +++ b/src/box/xrow.c @@ -186,6 +186,9 @@ error: flags = mp_decode_uint(pos); header->flags = flags; break; + case IPROTO_STREAM_ID: + header->stream_id = mp_decode_uint(pos); + break; default: /* unknown header */ mp_next(pos); @@ -319,6 +322,11 @@ xrow_header_encode(const struct xrow_header *header, uint64_t sync, flags_to_encode |= IPROTO_FLAG_COMMIT; } } + if (header->stream_id != 0) { + d = mp_encode_uint(d, IPROTO_STREAM_ID); + d = mp_encode_uint(d, header->stream_id); + map_size++; + } if (flags_to_encode != 0) { d = mp_encode_uint(d, IPROTO_FLAGS); d = mp_encode_uint(d, flags_to_encode); diff --git a/src/box/xrow.h b/src/box/xrow.h index 000cd6b88..44f9cbdd6 100644 --- a/src/box/xrow.h +++ b/src/box/xrow.h @@ -81,6 +81,11 @@ struct xrow_header { * transaction. */ int64_t tsn; + /** + * Stream id. Used in iproto binary protocol to identify stream. + * Zero if stream is not used. + */ + uint64_t stream_id; /** Transaction meta flags set only in the last transaction row. */ union { uint8_t flags; diff --git a/test/unit/xrow.cc b/test/unit/xrow.cc index b6018eed9..2c0dd88b6 100644 --- a/test/unit/xrow.cc +++ b/test/unit/xrow.cc @@ -220,8 +220,10 @@ test_xrow_header_encode_decode() header.bodycnt = 0; header.tsn = header.lsn; uint64_t sync = 100500; + uint64_t stream_id = 1; for (int opt_idx = 0; opt_idx < bit_comb_count; opt_idx++) { - plan(12); + plan(13); + header.stream_id = stream_id++; header.is_commit = opt_idx & 0x01; header.wait_sync = opt_idx >> 1 & 0x01; header.wait_ack = opt_idx >> 2 & 0x01; @@ -229,7 +231,7 @@ test_xrow_header_encode_decode() is(1, xrow_header_encode(&header, sync, vec, 200), "encode"); int fixheader_len = 200; pos = (char *)vec[0].iov_base + fixheader_len; - uint32_t exp_map_size = 5; + uint32_t exp_map_size = 6; /* * header.is_commit flag isn't encoded, since this row looks * like a single-statement transaction. @@ -249,6 +251,7 @@ test_xrow_header_encode_decode() end += vec[0].iov_len; is(xrow_header_decode(&decoded_header, &begin, end, true), 0, "header decode"); + is(header.stream_id, decoded_header.stream_id, "decoded stream_id"); is(header.is_commit, decoded_header.is_commit, "decoded is_commit"); is(header.wait_sync, decoded_header.wait_sync, "decoded wait_sync"); is(header.wait_ack, decoded_header.wait_ack, "decoded wait_ack"); diff --git a/test/unit/xrow.result b/test/unit/xrow.result index 3b705d5ba..1ca222d37 100644 --- a/test/unit/xrow.result +++ b/test/unit/xrow.result @@ -43,117 +43,125 @@ ok 1 - subtests 1..9 ok 1 - bad msgpack end - 1..12 + 1..13 ok 1 - encode ok 2 - header map size ok 3 - header decode - ok 4 - decoded is_commit - ok 5 - decoded wait_sync - ok 6 - decoded wait_ack - ok 7 - decoded type - ok 8 - decoded replica_id - ok 9 - decoded lsn - ok 10 - decoded tm - ok 11 - decoded sync - ok 12 - decoded bodycnt + ok 4 - decoded stream_id + ok 5 - decoded is_commit + ok 6 - decoded wait_sync + ok 7 - decoded wait_ack + ok 8 - decoded type + ok 9 - decoded replica_id + ok 10 - decoded lsn + ok 11 - decoded tm + ok 12 - decoded sync + ok 13 - decoded bodycnt ok 2 - subtests - 1..12 + 1..13 ok 1 - encode ok 2 - header map size ok 3 - header decode - ok 4 - decoded is_commit - ok 5 - decoded wait_sync - ok 6 - decoded wait_ack - ok 7 - decoded type - ok 8 - decoded replica_id - ok 9 - decoded lsn - ok 10 - decoded tm - ok 11 - decoded sync - ok 12 - decoded bodycnt + ok 4 - decoded stream_id + ok 5 - decoded is_commit + ok 6 - decoded wait_sync + ok 7 - decoded wait_ack + ok 8 - decoded type + ok 9 - decoded replica_id + ok 10 - decoded lsn + ok 11 - decoded tm + ok 12 - decoded sync + ok 13 - decoded bodycnt ok 3 - subtests - 1..12 + 1..13 ok 1 - encode ok 2 - header map size ok 3 - header decode - ok 4 - decoded is_commit - ok 5 - decoded wait_sync - ok 6 - decoded wait_ack - ok 7 - decoded type - ok 8 - decoded replica_id - ok 9 - decoded lsn - ok 10 - decoded tm - ok 11 - decoded sync - ok 12 - decoded bodycnt + ok 4 - decoded stream_id + ok 5 - decoded is_commit + ok 6 - decoded wait_sync + ok 7 - decoded wait_ack + ok 8 - decoded type + ok 9 - decoded replica_id + ok 10 - decoded lsn + ok 11 - decoded tm + ok 12 - decoded sync + ok 13 - decoded bodycnt ok 4 - subtests - 1..12 + 1..13 ok 1 - encode ok 2 - header map size ok 3 - header decode - ok 4 - decoded is_commit - ok 5 - decoded wait_sync - ok 6 - decoded wait_ack - ok 7 - decoded type - ok 8 - decoded replica_id - ok 9 - decoded lsn - ok 10 - decoded tm - ok 11 - decoded sync - ok 12 - decoded bodycnt + ok 4 - decoded stream_id + ok 5 - decoded is_commit + ok 6 - decoded wait_sync + ok 7 - decoded wait_ack + ok 8 - decoded type + ok 9 - decoded replica_id + ok 10 - decoded lsn + ok 11 - decoded tm + ok 12 - decoded sync + ok 13 - decoded bodycnt ok 5 - subtests - 1..12 + 1..13 ok 1 - encode ok 2 - header map size ok 3 - header decode - ok 4 - decoded is_commit - ok 5 - decoded wait_sync - ok 6 - decoded wait_ack - ok 7 - decoded type - ok 8 - decoded replica_id - ok 9 - decoded lsn - ok 10 - decoded tm - ok 11 - decoded sync - ok 12 - decoded bodycnt + ok 4 - decoded stream_id + ok 5 - decoded is_commit + ok 6 - decoded wait_sync + ok 7 - decoded wait_ack + ok 8 - decoded type + ok 9 - decoded replica_id + ok 10 - decoded lsn + ok 11 - decoded tm + ok 12 - decoded sync + ok 13 - decoded bodycnt ok 6 - subtests - 1..12 + 1..13 ok 1 - encode ok 2 - header map size ok 3 - header decode - ok 4 - decoded is_commit - ok 5 - decoded wait_sync - ok 6 - decoded wait_ack - ok 7 - decoded type - ok 8 - decoded replica_id - ok 9 - decoded lsn - ok 10 - decoded tm - ok 11 - decoded sync - ok 12 - decoded bodycnt + ok 4 - decoded stream_id + ok 5 - decoded is_commit + ok 6 - decoded wait_sync + ok 7 - decoded wait_ack + ok 8 - decoded type + ok 9 - decoded replica_id + ok 10 - decoded lsn + ok 11 - decoded tm + ok 12 - decoded sync + ok 13 - decoded bodycnt ok 7 - subtests - 1..12 + 1..13 ok 1 - encode ok 2 - header map size ok 3 - header decode - ok 4 - decoded is_commit - ok 5 - decoded wait_sync - ok 6 - decoded wait_ack - ok 7 - decoded type - ok 8 - decoded replica_id - ok 9 - decoded lsn - ok 10 - decoded tm - ok 11 - decoded sync - ok 12 - decoded bodycnt + ok 4 - decoded stream_id + ok 5 - decoded is_commit + ok 6 - decoded wait_sync + ok 7 - decoded wait_ack + ok 8 - decoded type + ok 9 - decoded replica_id + ok 10 - decoded lsn + ok 11 - decoded tm + ok 12 - decoded sync + ok 13 - decoded bodycnt ok 8 - subtests - 1..12 + 1..13 ok 1 - encode ok 2 - header map size ok 3 - header decode - ok 4 - decoded is_commit - ok 5 - decoded wait_sync - ok 6 - decoded wait_ack - ok 7 - decoded type - ok 8 - decoded replica_id - ok 9 - decoded lsn - ok 10 - decoded tm - ok 11 - decoded sync - ok 12 - decoded bodycnt + ok 4 - decoded stream_id + ok 5 - decoded is_commit + ok 6 - decoded wait_sync + ok 7 - decoded wait_ack + ok 8 - decoded type + ok 9 - decoded replica_id + ok 10 - decoded lsn + ok 11 - decoded tm + ok 12 - decoded sync + ok 13 - decoded bodycnt ok 9 - subtests ok 2 - subtests 1..1 -- 2.20.1