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 2364B6BD29; Tue, 13 Apr 2021 14:50:42 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 2364B6BD29 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1618314642; bh=lUG1Q49p4rg9ZwUoJ2kXvWWqkNTkl1H4pxy0tVQss+0=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=Ay1L0CmZTSWoBTYTglQnePEIvaYvLm6xOTa/RrTXq8ChD/5CXnU+GrFArrxA650WK Tvy90eBSjJjK9owmIeTtimvY+4+GtUaXFom3s61OZ8vJcCvRaX0c/s6T5E7RRoOEgo r+6hBc5u1c8zddgIEmRG/d6GP7ICieBwIzvUxz5w= Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id B80CF6BD29 for ; Tue, 13 Apr 2021 14:50:40 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B80CF6BD29 Received: by mail-lf1-f51.google.com with SMTP id b4so26823757lfi.6 for ; Tue, 13 Apr 2021 04:50:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=g3idikkeMBwMgojNJBn/46bGXWVdaXG+mQiqTLtOdiI=; b=pmRIJyjVOExoxACYgUL7o6kbVjk3+y8T+H8Z3fY5fbNzw5k26ybo5EvGhUWK3ytKc7 YPkQj7bC5aptV9BY69Zk6sSr5Zvly4aQ6YHy/OYtfM204CnYOJbe6A+m1Lee5v650r4e FJS4/hBH8mNYTvvT+432eUmv6DqjManTmJxElWnU3cqdBoqWAF7dUHRGi7NR/9Bd2rTO CzvOe47QmJelGuKl/7zVcxtHitWJd43zCwUF/8sIVuHhN7GO8kZKg78otQ3o2NQyS6pp pryZ4K7vYpT16WbamwVuf2AIxXcRGoYcXOKQVqP3XzqzZXAzrSl8ujpFjrIPCeJhZpfn 82dg== X-Gm-Message-State: AOAM531P22BhmoGppWh+XO/E0+DcFR1QQAuN9zZt6o0PZX80O4cwrJpI Gfgz0eBW3JmXTJtJ+zCOufb1fnWBogQ= X-Google-Smtp-Source: ABdhPJz4Qwt+ccEzaQy5tMpxjmjJLZ4O/Nj38C6r9sIAeIb9ABluhv8okK04/ABPr/Iay3d1WWdXFw== X-Received: by 2002:a05:6512:3703:: with SMTP id z3mr22094961lfr.358.1618314639460; Tue, 13 Apr 2021 04:50:39 -0700 (PDT) Received: from grain.localdomain ([5.18.199.94]) by smtp.gmail.com with ESMTPSA id a1sm3271647lfh.142.2021.04.13.04.50.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Apr 2021 04:50:37 -0700 (PDT) Received: by grain.localdomain (Postfix, from userid 1000) id D132D560162; Tue, 13 Apr 2021 14:50:36 +0300 (MSK) Date: Tue, 13 Apr 2021 14:50:36 +0300 To: Serge Petrenko Cc: v.shpilevoy@tarantool.org, tarantool-patches@dev.tarantool.org Message-ID: References: <0d29b025b7213b5c9596715d849b4b371e1fef32.1618256019.git.sergepetrenko@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0d29b025b7213b5c9596715d849b4b371e1fef32.1618256019.git.sergepetrenko@tarantool.org> User-Agent: Mutt/2.0.5 (2021-01-21) 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: Cyrill Gorcunov via Tarantool-patches Reply-To: Cyrill Gorcunov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 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? The patch is on top of your series. --- >From 8de9e03d5bf7ed5fd88d6d903bd7abef7a32286a Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Tue, 13 Apr 2021 14:47:40 +0300 Subject: [PATCH] test/unit: xrow -- verify bitfields order Part-of #5445 Signed-off-by: Cyrill Gorcunov --- test/unit/xrow.cc | 31 ++++++++++++++++++++++++++++++- test/unit/xrow.result | 7 ++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/test/unit/xrow.cc b/test/unit/xrow.cc index ea1ee1767..047f3330d 100644 --- a/test/unit/xrow.cc +++ b/test/unit/xrow.cc @@ -297,12 +297,40 @@ 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(3); + + struct xrow_header header; + + memset(&header, 0, sizeof(header)); + + header.is_commit = 1; + ok(header.opt_flags == IPROTO_FLAG_COMMIT, "header.is_commit"); + header.is_commit = 0; + + header.wait_sync = 1; + ok(header.opt_flags == IPROTO_FLAG_WAIT_SYNC, "header.wait_sync"); + header.wait_sync = 0; + + header.wait_ack = 1; + ok(header.opt_flags == IPROTO_FLAG_WAIT_ACK, "header.wait_ack"); + header.wait_ack = 0; + + check_plan(); +} + int main(void) { memory_init(); fiber_init(fiber_c_invoke); - plan(3); + plan(4); random_init(); @@ -310,6 +338,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..bd8a475fc 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,8 @@ ok 2 - subtests 1..1 ok 1 - request_str ok 3 - subtests + 1..3 + ok 1 - header.is_commit + ok 2 - header.wait_sync + ok 3 - header.wait_ack +ok 4 - subtests -- 2.30.2