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 C441E6B95B; Tue, 13 Apr 2021 16:51:55 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C441E6B95B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1618321915; bh=VUZcy2zSEmo76FnTzlpkuK/nk7ElrxzCIBnnTj+3TUo=; 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=F94IRGC4UW4SWoAZnLPft1GAv9FGNVli+CUjhboHAJTO54ap3SjzeMty7JY1UqLCu zmENJqCC8xBaYMZUEMsjF9EB8/nH59lvi0ZF08SxxBkCGQN0fActlDe5Hhc03rHvc5 R+aPvCYNgV10NrVNjylNChnrzbDlnMTbDlQi3kBc= Received: from smtp43.i.mail.ru (smtp43.i.mail.ru [94.100.177.103]) (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 271106B957 for ; Tue, 13 Apr 2021 16:51:55 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 271106B957 Received: by smtp43.i.mail.ru with esmtpa (envelope-from ) id 1lWJSM-0005Wn-CQ; Tue, 13 Apr 2021 16:51:54 +0300 To: Cyrill Gorcunov Cc: v.shpilevoy@tarantool.org, tarantool-patches@dev.tarantool.org References: <0d29b025b7213b5c9596715d849b4b371e1fef32.1618256019.git.sergepetrenko@tarantool.org> Message-ID: <90b3cd45-b633-e7e1-8547-0e04aebcf522@tarantool.org> Date: Tue, 13 Apr 2021 16:51:52 +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: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD92FFCB8E6708E74807BAE725B9AE625DE765B0E193B5B7687182A05F5380850401DBAD7135793F2DAFFB6F1AA61673BF1D1A55BD1C876ECDEE90B39BB249B7013 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE76042E2DB3E33BF2BEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637486F32EF78EC606F8638F802B75D45FF914D58D5BE9E6BC1A93B80C6DEB9DEE97C6FB206A91F05B29DE8403E8A05EAD9F1CCFD48E86898C3E695ED7F9A6C896ED2E47CDBA5A96583C09775C1D3CA48CF3F395433950BAD63117882F4460429724CE54428C33FAD30A8DF7F3B2552694AC26CFBAC0749D213D2E47CDBA5A9658378DA827A17800CE778FCF50C7EAF9C588941B15DA834481F9449624AB7ADAF37BA3038C0950A5D3613377AFFFEAFD2691661749BA6B9773544E78C7E28D475B77B076A6E789B0E97A8DF7F3B2552694A1E7802607F20496D49FD398EE364050FB28585415E75ADA9B1CA5D0BF4193578B3661434B16C20AC78D18283394535A9E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6753C3A5E0A5AB5B7089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A5FBBEFDBECAF345A794AE7C6E97D40F873213D9601BA94316D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7502E6951B79FF9A3F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34D9DC20663B80603F806ABFF5E4EA14910126B1775C3D767D50D1B28640D6BA272BB565F03ABB03D21D7E09C32AA3244C7069F282907790A2B54E0F72C37DF3A33FD9C8CA1B0515E0FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojnA7/qPBUIXEp9qOrYHaKUw== X-Mailru-Sender: 583F1D7ACE8F49BDD2846D59FC20E9F8CEDB292DAB1B8438683DAA522BFF28512F1FDEFAAAF8DC8B424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v2 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" 13.04.2021 14:50, Cyrill Gorcunov пишет: > On Mon, Apr 12, 2021 at 10:40:14PM +0300, Serge Petrenko wrote: >> 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 > Serge, here is a one addition: lets verify bitfields order. While their > use indeed is suitable we should eliminate ourself from unpredicted results. > The test is for c++ and probably we need one for plain c compiler as well? Thanks for the help! I've added your tests with some changes. What do you think? =========================== diff --git a/test/unit/xrow.cc b/test/unit/xrow.cc index ea1ee1767..3d7d8bee1 100644 --- a/test/unit/xrow.cc +++ b/test/unit/xrow.cc @@ -297,12 +297,49 @@ test_request_str()      check_plan();  } +/** + * The compiler doesn't have to preserve bitfields order, + * still we rely on it for convenience sake. + */ +static void +test_xrow_opt_field() +{ +    plan(6); + +    struct xrow_header header; + +    memset(&header, 0, sizeof(header)); + +    header.is_commit = true; +    is(header.opt_flags, IPROTO_FLAG_COMMIT, "header.is_commit -> COMMIT"); +    header.is_commit = false; + +    header.wait_sync = true; +    is(header.opt_flags, IPROTO_FLAG_WAIT_SYNC, "header.wait_sync -> WAIT_SYNC"); +    header.wait_sync = false; + +    header.wait_ack = true; +    is(header.opt_flags, IPROTO_FLAG_WAIT_ACK, "header.wait_ack -> WAIT_ACK"); +    header.wait_ack = false; + +    header.opt_flags = IPROTO_FLAG_COMMIT; +    ok(header.is_commit && !header.wait_sync && !header.wait_ack, "COMMIT -> header.is_commit"); + +    header.opt_flags = IPROTO_FLAG_WAIT_SYNC; +    ok(!header.is_commit && header.wait_sync && !header.wait_ack, "WAIT_SYNC -> header.wait_sync"); + +    header.opt_flags = IPROTO_FLAG_WAIT_ACK; +    ok(!header.is_commit && !header.wait_sync && header.wait_ack, "WAIT_ACK -> header.wait_ack"); + +    check_plan(); +} +  int  main(void)  {      memory_init();      fiber_init(fiber_c_invoke); -    plan(3); +    plan(4);      random_init(); @@ -310,6 +347,7 @@ main(void)      test_greeting();      test_xrow_header_encode_decode();      test_request_str(); +    test_xrow_opt_field();      random_free();      fiber_free(); diff --git a/test/unit/xrow.result b/test/unit/xrow.result index e06ba5261..3b705d5ba 100644 --- a/test/unit/xrow.result +++ b/test/unit/xrow.result @@ -1,4 +1,4 @@ -1..3 +1..4      1..40      ok 1 - round trip      ok 2 - roundtrip.version_id @@ -159,3 +159,11 @@ ok 2 - subtests      1..1      ok 1 - request_str  ok 3 - subtests +    1..6 +    ok 1 - header.is_commit -> COMMIT +    ok 2 - header.wait_sync -> WAIT_SYNC +    ok 3 - header.wait_ack -> WAIT_ACK +    ok 4 - COMMIT -> header.is_commit +    ok 5 - WAIT_SYNC -> header.wait_sync +    ok 6 - WAIT_ACK -> header.wait_ack +ok 4 - subtests -- Serge Petrenko