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 BEE626EC5B; Mon, 12 Apr 2021 22:21:32 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org BEE626EC5B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1618255292; bh=MLn1nwK6VSJXeTmu8094XDqF0tuhpwCVG4CPC7B8Tk8=; h=To:Cc:References:Date:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=AOrEXaUyhEq7Y7W1bZfe273x2QBlyfNRuLtO4Bst0B5lNdtvIa+JqnM892v73okmz U+1UXrnIFn2WRWLeiWYBx62tt+yUKGFCcZ2+0NdArbu47DALPbMHDUK58tvvQcQhT9 ihtP/tEziTWwWTRnj+ZLns9mXotfkZURYxIYR9CY= 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 65B716EC5B for ; Mon, 12 Apr 2021 22:21:30 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 65B716EC5B Received: by smtp33.i.mail.ru with esmtpa (envelope-from ) id 1lW27l-00041p-Iq; Mon, 12 Apr 2021 22:21:30 +0300 To: v.shpilevoy@tarantool.org, gorcunov@gmail.com Cc: tarantool-patches@dev.tarantool.org References: <69fd9b54dcaf92116e08d3319a66c080ad578cea.1618163409.git.sergepetrenko@tarantool.org> Message-ID: <0a7cc1ab-35e8-172d-ed42-02ffe535d2b5@tarantool.org> Date: Mon, 12 Apr 2021 22:21:29 +0300 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 MIME-Version: 1.0 In-Reply-To: <69fd9b54dcaf92116e08d3319a66c080ad578cea.1618163409.git.sergepetrenko@tarantool.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD92FFCB8E6708E7480257C85EA0BB7A95D5E28B957962BB550182A05F5380850406473F0FCD8E4DF23A54C983ED5EBDAEBF7CE43F5036D4D853241450760841F55 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7B114C2C2C20B7E62EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AD1E1BF10F09609D8638F802B75D45FF914D58D5BE9E6BC1A93B80C6DEB9DEE97C6FB206A91F05B2368839B99D42F07E2C05F3C76C00284DFEEB761FB9071033D2E47CDBA5A96583C09775C1D3CA48CF17B107DEF921CE79117882F4460429724CE54428C33FAD30A8DF7F3B2552694AC26CFBAC0749D213D2E47CDBA5A9658378DA827A17800CE7328B01A8D746D8839FA2833FD35BB23DF004C90652538430302FCEF25BFAB3454AD6D5ED66289B5278DA827A17800CE727A880FE3FB2E621D32BA5DBAC0009BE395957E7521B51C20BC6067A898B09E4090A508E0FED6299176DF2183F8FC7C046DA754BBE08B471CD04E86FAF290E2D7E9C4E3C761E06A71DD303D21008E298D5E8D9A59859A8B6B372FE9A2E580EFC725E5C173C3A84C30584FF81F342DA0735872C767BF85DA2F004C90652538430E4A6367B16DE6309 X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2368A440D3B0F6089093C9A16E5BC824A2A04A2ABAA09D25379311020FFC8D4ADF048BB164F7B76AFE43925F31DDB1EA6 X-C1DE0DAB: 0D63561A33F958A516A29CCE73A941F7D4AFFC11AE578CD175DDBD215D242E3BD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7502E6951B79FF9A3F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3473688ED311681BF029E00E84A59AC4B76BFA46A1828FC4121B3B76CC99130B3F0EAB424287F516081D7E09C32AA3244CF019ED09DE55B071F6C7FA2CCB51CA18435BF7150578642FFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojq8JA+pXcDum/PI8qjq2SiQ== X-Mailru-Sender: 583F1D7ACE8F49BDD2846D59FC20E9F84B6D92528DBD2F05CBF99A3949BD426B191FF8DA59C9521C424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH 1/9] wal: enrich row's meta information with sync replication flags 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 Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 11.04.2021 20:55, Serge Petrenko пишет: > Introduce two new flags to xrow_header: `wait_ack` and `wait_sync`. > These flags are set for rows belonging to synchronous transactions in > addition to `is_commit`. > > The new flags help to define whether the rows belong to a synchronous > transaction or not without parsing them all and checking whether any of > the rows touches a synchronous space. > > This will be used in applier once it is taught to filter synchronous > transactions based on whether they are coming from a raft leader or not. > > P.S. These flags will also be useful once we allow to turn any transaction > synchronous. Once this is done, the flags in row header will be the only > source of information on whether the transaction is synchronous or not. > > Prerequisite #5445 Force-pushed a test: ===================================== diff --git a/test/unit/xrow.cc b/test/unit/xrow.cc index 9fd154719..ea1ee1767 100644 --- a/test/unit/xrow.cc +++ b/test/unit/xrow.cc @@ -204,7 +204,9 @@ test_greeting()  void  test_xrow_header_encode_decode()  { -    plan(10); +    /* Test all possible 3-bit combinations. */ +    const int bit_comb_count = 1 << 3; +    plan(1 + bit_comb_count);      struct xrow_header header;      char buffer[2048];      char *pos = mp_encode_uint(buffer, 300); @@ -217,27 +219,47 @@ test_xrow_header_encode_decode()      header.tm = 123.456;      header.bodycnt = 0;      header.tsn = header.lsn; -    header.is_commit = true;      uint64_t sync = 100500; -    struct iovec vec[1]; -    is(1, xrow_header_encode(&header, sync, vec, 200), "encode"); -    int fixheader_len = 200; -    pos = (char *)vec[0].iov_base + fixheader_len; -    is(mp_decode_map((const char **)&pos), 5, "header map size"); - -    struct xrow_header decoded_header; -    const char *begin = (const char *)vec[0].iov_base; -    begin += fixheader_len; -    const char *end = (const char *)vec[0].iov_base; -    end += vec[0].iov_len; -    is(xrow_header_decode(&decoded_header, &begin, end, true), 0, -       "header decode"); -    is(header.type, decoded_header.type, "decoded type"); -    is(header.replica_id, decoded_header.replica_id, "decoded replica_id"); -    is(header.lsn, decoded_header.lsn, "decoded lsn"); -    is(header.tm, decoded_header.tm, "decoded tm"); -    is(decoded_header.sync, sync, "decoded sync"); -    is(decoded_header.bodycnt, 0, "decoded bodycnt"); +    for (int opt_idx = 0; opt_idx < bit_comb_count; opt_idx++) { +        plan(12); +        header.is_commit = opt_idx & 0x01; +        header.wait_sync = opt_idx >> 1 & 0x01; +        header.wait_ack = opt_idx >> 2 & 0x01; +        struct iovec vec[1]; +        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; +        /* +         * header.is_commit flag isn't encoded, since this row looks +         * like a single-statement transaction. +         */ +        if (header.wait_sync || header.wait_ack) +            exp_map_size += 1; +        /* tsn is encoded explicitly in this case. */ +        if (!header.is_commit) +            exp_map_size += 1; +        uint32_t size = mp_decode_map((const char **)&pos); +        is(size, exp_map_size, "header map size"); + +        struct xrow_header decoded_header; +        const char *begin = (const char *)vec[0].iov_base; +        begin += fixheader_len; +        const char *end = (const char *)vec[0].iov_base; +        end += vec[0].iov_len; +        is(xrow_header_decode(&decoded_header, &begin, end, true), 0, +           "header decode"); +        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"); +        is(header.type, decoded_header.type, "decoded type"); +        is(header.replica_id, decoded_header.replica_id, "decoded replica_id"); +        is(header.lsn, decoded_header.lsn, "decoded lsn"); +        is(header.tm, decoded_header.tm, "decoded tm"); +        is(decoded_header.sync, sync, "decoded sync"); +        is(decoded_header.bodycnt, 0, "decoded bodycnt"); +        check_plan(); +    }      check_plan();  } diff --git a/test/unit/xrow.result b/test/unit/xrow.result index 5ee92ad7b..e06ba5261 100644 --- a/test/unit/xrow.result +++ b/test/unit/xrow.result @@ -41,17 +41,120 @@      ok 39 - invalid 10      ok 40 - invalid 11  ok 1 - subtests -    1..10 +    1..9      ok 1 - bad msgpack end -    ok 2 - encode -    ok 3 - header map size -    ok 4 - header decode -    ok 5 - decoded type -    ok 6 - decoded replica_id -    ok 7 - decoded lsn -    ok 8 - decoded tm -    ok 9 - decoded sync -    ok 10 - decoded bodycnt +        1..12 +        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 2 - subtests +        1..12 +        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 3 - subtests +        1..12 +        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 - subtests +        1..12 +        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 5 - subtests +        1..12 +        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 6 - subtests +        1..12 +        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 7 - subtests +        1..12 +        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 8 - subtests +        1..12 +        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 9 - subtests  ok 2 - subtests      1..1      ok 1 - request_str -- Serge Petrenko