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 7A41F6FC8F; Fri, 16 Apr 2021 17:03:51 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 7A41F6FC8F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1618581831; bh=WObzaJEJF39C4TLYQUelLHRbvaMYSiqpWVulCBY/qdE=; 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=BV6HURlqwMO+meCCcX1IKe/wJxNryyiGkTgf7tvt7aPbKy8AaZ5yWF/fjzD/s3I8o Hmz2aOP0I+TLrQlwcXFq/tpwPDwZK3IQ4NkuaDpdcno6rIFdkEID1a93m+8EPGkb6f KIWmVtyqLfdvuK5gn7OLSfLht73r0FMny9Dfumm8= Received: from smtp49.i.mail.ru (smtp49.i.mail.ru [94.100.177.109]) (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 F3FE76FC8F for ; Fri, 16 Apr 2021 17:03:49 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org F3FE76FC8F Received: by smtp49.i.mail.ru with esmtpa (envelope-from ) id 1lXP4X-0002mg-6h; Fri, 16 Apr 2021 17:03:49 +0300 To: Vladislav Shpilevoy , gorcunov@gmail.com Cc: tarantool-patches@dev.tarantool.org References: <63f4e63825172aaad50b910ed7c0431246380d45.1618409665.git.sergepetrenko@tarantool.org> <704bbea0-f575-4253-630c-eff5c6a269bd@tarantool.org> Message-ID: <0a38573d-f8e9-b069-fd31-396a566049c3@tarantool.org> Date: Fri, 16 Apr 2021 17:03:48 +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: <704bbea0-f575-4253-630c-eff5c6a269bd@tarantool.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD92FFCB8E6708E7480257C85EA0BB7A95D0F00AE41BB9A5343182A05F5380850408A3B98E0C3CE512D41C83F21C7B301522EC1885551743B5B7DCE0F6C91484103 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7B3C0829F48AFDC41EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006379D15B32FCF98DF428638F802B75D45FF914D58D5BE9E6BC1A93B80C6DEB9DEE97C6FB206A91F05B2BDB6CAFFE9F2749BB7FDBB96DE7844B189428004B1FE94FDD2E47CDBA5A96583C09775C1D3CA48CF4964A708C60C975A117882F4460429724CE54428C33FAD30A8DF7F3B2552694AC26CFBAC0749D213D2E47CDBA5A9658378DA827A17800CE7ABB305BD10C6E5099FA2833FD35BB23DF004C90652538430302FCEF25BFAB3454AD6D5ED66289B5278DA827A17800CE72F0A70CDD3C219CFD32BA5DBAC0009BE395957E7521B51C20BC6067A898B09E4090A508E0FED6299176DF2183F8FC7C098F20EE13D97131ECD04E86FAF290E2D7E9C4E3C761E06A71DD303D21008E298D5E8D9A59859A8B6B372FE9A2E580EFC725E5C173C3A84C3CE9959E2676FD87735872C767BF85DA2F004C90652538430E4A6367B16DE6309 X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2AD77751E876CB595E8F7B195E1C97831827CA068B525065D294F1ADDE986B152 X-C1DE0DAB: 0D63561A33F958A5C0A72A3DAB9C46B422DB986D197C1FE5572381C05C6E11B3D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7502E6951B79FF9A3F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D343F22CE0A71FDB37E845A4011F63B1248181A86AB910869F09C12EAF0BDF3D42B24AC2EB2930E07C11D7E09C32AA3244C3273A5539E39D1CC49360CF0A616B5E5C86C126E7119A0FEFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj3S6P1v0GIqTN9JcJXzQWgQ== X-Mailru-Sender: 583F1D7ACE8F49BDD2846D59FC20E9F856EF5812A156B1AB9A40916F28D599A0911FC8635B099D6E424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v3 04/10] box: make clear_synchro_queue() write a PROMOTE entry instead of CONFIRM + ROLLBACK 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" 16.04.2021 12:28, Serge Petrenko via Tarantool-patches пишет: > > > 16.04.2021 02:20, Vladislav Shpilevoy пишет: >> Thanks for working on this! >> >> See 2 comments below. >> >>> diff --git a/src/box/box.cc b/src/box/box.cc >>> index 70b325180..9adb6ba46 100644 >>> --- a/src/box/box.cc >>> +++ b/src/box/box.cc >>> @@ -1556,7 +1556,19 @@ box_clear_synchro_queue(bool try_wait) >>>                    "new synchronous transactions appeared"); >>>               rc = -1; >>>           } else { >>> -            txn_limbo_force_empty(&txn_limbo, wait_lsn); >>> +            /* >>> +             * Term parameter is unused now, We'll pass >>> +             * box_raft()->term there later. >>> +             */ >>> +            txn_limbo_write_promote(&txn_limbo, wait_lsn, 0); >>> +            struct synchro_request req = { >>> +                .type = 0, /* unused */ >>> +                .replica_id = 0, /* unused */ >>> +                .origin_id = instance_id, >>> +                .lsn = wait_lsn, >>> +                .term = 0, /* unused */ >> 1. Aren't the unused fields nullified anyway according to >> the standard? > > We had this conversation with Cyrill recently. I don't have a good > explanation > for this anyway, but here's the one I have: > >>> Is there some particular meaning of zeroifying designated assignments? >>> I mean why not simply >>> >>>             struct synchro_request req = { >>>                 .origin_id    = instance_id, >>>                 .lsn        = wait_lsn, >>>             }; >>> >>> or you wanted to pay attention that the left of the fields are >>> unused? Just curious, I'm fine with current code. >> I went for your option at first, and it's the one I'd prefer. >> But with it I got failed builds in some CI jobs. >> >> It said something like "sorry, not yet implemented: struct partial >> initialization" >> > > >> >>> +            }; >>> +            txn_limbo_read_promote(&txn_limbo, &req); >>>               assert(txn_limbo_is_empty(&txn_limbo)); >>>           } >>>       } >>> diff --git a/src/box/txn_limbo.c b/src/box/txn_limbo.c >>> index d29722ef7..bfe0ad302 100644 >>> --- a/src/box/txn_limbo.c >>> +++ b/src/box/txn_limbo.c >>> @@ -464,6 +470,32 @@ txn_limbo_read_rollback(struct txn_limbo >>> *limbo, int64_t lsn) >>>           box_update_ro_summary(); >>>   } >>>   +void >>> +txn_limbo_write_promote(struct txn_limbo *limbo, int64_t lsn, >>> uint64_t term) >>> +{ >>> +    limbo->confirmed_lsn = lsn; >>> +    /* >>> +     * We make sure that promote is only written once everything this >>> +     * instance has may be confirmed. >>> +     */ >>> +    struct txn_limbo_entry *e = txn_limbo_last_synchro_entry(limbo); >>> +    assert(e == NULL || e->lsn <= lsn); >>> +    (void) e; >>> +    txn_limbo_write_synchro(limbo, IPROTO_PROMOTE, lsn, term); >>> +    limbo->is_in_rollback = false; >> 2. How is it possible that there was a rollback in progress at >> the same time? > > Sorry, I was trying to replicate txn_limbo_write_confirm/rollback > behaviour, > but forgot to set limbo->is_in_rollback = true before the journal write: > > ======================================= > > diff --git a/src/box/txn_limbo.c b/src/box/txn_limbo.c > index e6f644bc0..93c8994b7 100644 > --- a/src/box/txn_limbo.c > +++ b/src/box/txn_limbo.c > @@ -474,6 +474,7 @@ void >  txn_limbo_write_promote(struct txn_limbo *limbo, int64_t lsn, > uint64_t term) >  { >         limbo->confirmed_lsn = lsn; > +       limbo->is_in_rollback = true; >         /* >          * We make sure that promote is only written once everything this >          * instance has may be confirmed. > > > One more diff on top: ======================================== diff --git a/src/box/box.cc b/src/box/box.cc index 73a9da56a..e0bed74f1 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -1562,13 +1562,13 @@ box_clear_synchro_queue(bool try_wait)                          */                         txn_limbo_write_promote(&txn_limbo, wait_lsn, 0);                         struct synchro_request req = { -                               .type = 0, /* unused */ -                               .replica_id = 0, /* unused */ +                               .type = IPROTO_PROMOTE, +                               .replica_id = former_leader_id,                                 .origin_id = instance_id,                                 .lsn = wait_lsn,                                 .term = 0, /* unused */                         }; -                       txn_limbo_read_promote(&txn_limbo, &req); +                       txn_limbo_process(&txn_limbo, &req); assert(txn_limbo_is_empty(&txn_limbo));                 }         } diff --git a/src/box/txn_limbo.c b/src/box/txn_limbo.c index 93c8994b7..6657990e8 100644 --- a/src/box/txn_limbo.c +++ b/src/box/txn_limbo.c @@ -486,7 +486,11 @@ txn_limbo_write_promote(struct txn_limbo *limbo, int64_t lsn, uint64_t term)         limbo->is_in_rollback = false;  } -void +/** + * Process a PROMOTE request, i.e. confirm all entries <= @req.lsn and rollback all + * entries > @req.lsn. + */ +static void  txn_limbo_read_promote(struct txn_limbo *limbo,                        const struct synchro_request *req)  { diff --git a/src/box/txn_limbo.h b/src/box/txn_limbo.h index 4a1c43856..f35771dc9 100644 --- a/src/box/txn_limbo.h +++ b/src/box/txn_limbo.h @@ -278,14 +278,6 @@ txn_limbo_wait_confirm(struct txn_limbo *limbo);  void  txn_limbo_write_promote(struct txn_limbo *limbo, int64_t lsn, uint64_t term); -/** - * Process a PROMOTE request, i.e. confirm all entries <= @req.lsn and rollback all - * entries > @req.lsn. - */ -void -txn_limbo_read_promote(struct txn_limbo *limbo, -                      const struct synchro_request *req); -  /**   * Update qsync parameters dynamically.   */ -- Serge Petrenko