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 B197A6EC55; Thu, 29 Jul 2021 23:47:43 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B197A6EC55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1627591663; bh=2Slz1RS4x2oyZd1AwS893kUxLiBS+WJSMEFl3etSjoo=; 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=MPMwPvOff68O3/MQuMAz4PqKSvgBZoS+WeZkfwnVcbViep8TBk6EoNOtvrfcSxPnY 7jD8cX7saPij4QxO1cp8FHc0zEWWgO0EIXSnqSnagjFLKN0O5IT66Z9Vlc5WhIAmH4 NA3e9LX7a8NrUiNYMKb2/L9gN3jNdKvrERVGCvTc= Received: from smtp3.mail.ru (smtp3.mail.ru [94.100.179.58]) (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 1CA306EC55 for ; Thu, 29 Jul 2021 23:46:54 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1CA306EC55 Received: by smtp3.mail.ru with esmtpa (envelope-from ) id 1m9Cvd-00077O-HO; Thu, 29 Jul 2021 23:46:53 +0300 To: Vladislav Shpilevoy , gorcunov@gmail.com Cc: tarantool-patches@dev.tarantool.org References: <82fb422a-7a6c-d52f-06ba-8e053b2cd8bb@tarantool.org> Message-ID: <45a9ea6e-d72e-b2d7-c8b9-0454e6f3a2a3@tarantool.org> Date: Thu, 29 Jul 2021 23:46:52 +0300 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <82fb422a-7a6c-d52f-06ba-8e053b2cd8bb@tarantool.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD941C43E597735A9C351B198F4576AC7B21928AAE70459C21B182A05F538085040071F04011494A6B605908FAD4577A095F5FB260F71E83A42D547FCE2EFFB92E8 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE75FDD7770C76D593DEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006372D850D7477D401F58638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8DC15CAF9ED76A7D9FAA5C1C6BF200D9F117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC00AB816903775DDCA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735209647ADFADE5905B1618001F51B5FD3F9D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE4B6963042765DA4B3DBBCB839D0549ACD8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE3FA486DC37A503D0B6136E347CC761E07C4224003CC836476EA7A3FFF5B025636E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F790063788B3B24285A3CD0EEFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A213B5FB47DCBC3458F0AFF96BAACF4158235E5A14AD4A4A4625E192CAD1D9E79DB53CE8437368708930E3547D2D6BC178 X-C1DE0DAB: 0D63561A33F958A51C931BCA81D3E4F44E1D41402114AFF365FE6D3E36D57884D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7536C62C4FBC402878410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34411AA3F52B5778B60934DCFC6C2A69AC71C1DC6DA6DA04E49E028A6C47FD5CC291C13EAFF6BDA3341D7E09C32AA3244C23EED950C2A20FDD1CF80BC2902395BE64EE5813BBCA3A9DFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojPp/mPgZxawFjV0z4UmPU7w== X-Mailru-Sender: 9482C2B233321BD27EE33DDA534ACD91E08817B2D48BFB1967161E7DC7FDB8096316C4F50B5832986BB2E709EA627F343C7DDD459B58856F0E45BC603594F5A135B915D4279FF0579437F6177E88F7363CDA0F3B3F5B9367 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v4 10/16] box: make promote always bump the term 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: Sergey Petrenko via Tarantool-patches Reply-To: Sergey Petrenko Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 27.07.2021 02:45, Vladislav Shpilevoy пишет: > Thanks for the fixes! > >> diff --git a/src/box/raft.c b/src/box/raft.c >> index eb62e9630..35c471f58 100644 >> --- a/src/box/raft.c >> +++ b/src/box/raft.c >> @@ -394,6 +394,46 @@ box_raft_wait_term_outcome(void) > <...> > >> + >> +int >> +box_raft_wait_term_persisted(void) >> +{ >> + if (box_raft()->term == box_raft()->volatile_term) >> + return 0; >> + struct raft_wait_persisted_data data = { >> + .waiter = fiber(), >> + .term = box_raft()->volatile_term, >> + }; >> + struct trigger trig; >> + trigger_create(&trig, box_raft_wait_term_persisted_f, &data, NULL); >> + raft_on_update(box_raft(), &trig); >> + >> + do { >> + fiber_yield(); >> + } while (box_raft()->term < data.term && !fiber_is_cancelled()); > Could I ask you please to cache box_raft() into a variable? > It would be shorter and slightly easier to read. Sure. Done. =========================== diff --git a/src/box/raft.c b/src/box/raft.c index 35c471f58..bef9414c3 100644 --- a/src/box/raft.c +++ b/src/box/raft.c @@ -412,19 +412,20 @@ box_raft_wait_term_persisted_f(struct trigger *trig, void *event)  int  box_raft_wait_term_persisted(void)  { -       if (box_raft()->term == box_raft()->volatile_term) +       struct raft *raft = box_raft(); +       if (raft->term == raft->volatile_term)                 return 0;         struct raft_wait_persisted_data data = {                 .waiter = fiber(), -               .term = box_raft()->volatile_term, +               .term = raft->volatile_term,         };         struct trigger trig;         trigger_create(&trig, box_raft_wait_term_persisted_f, &data, NULL); -       raft_on_update(box_raft(), &trig); +       raft_on_update(raft, &trig);         do {                 fiber_yield(); -       } while (box_raft()->term < data.term && !fiber_is_cancelled()); +       } while (raft->term < data.term && !fiber_is_cancelled());         trigger_clear(&trig);         if (fiber_is_cancelled()) { =========================== >> + >> + trigger_clear(&trig); >> + if (fiber_is_cancelled()) { >> + diag_set(FiberIsCancelled); >> + return -1; >> + } >> + return 0; >> +}