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 B07AA6EC5F; Wed, 21 Apr 2021 08:59:31 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B07AA6EC5F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1618984771; bh=S/APoO1qIdF2zJLTAc7fIQ9AQTItVgbeovdpePa+eK0=; 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=N1ebByLODv3Xp2DunLLSJg49dg5xaZTAidkWwrBBYFQBGx+6G6jJ98kzroRPRUB3S xxrtgjjujrI79ltWE66c6OoZtp4OlcCUBLv7ie+ovSFmA1YghqVsJkJ5X6sU/qqevA qF8SYvll3ttDQDeYD/V2z2Pyccf7yhKzhADJM2Ns= Received: from smtp56.i.mail.ru (smtp56.i.mail.ru [217.69.128.36]) (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 8B34C6EC5F for ; Wed, 21 Apr 2021 08:59:20 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 8B34C6EC5F Received: by smtp56.i.mail.ru with esmtpa (envelope-from ) id 1lZ5tP-0002fT-Us; Wed, 21 Apr 2021 08:59:20 +0300 To: Vladislav Shpilevoy , gorcunov@gmail.com Cc: tarantool-patches@dev.tarantool.org References: <5cbaefa9-078a-b00c-2aec-75cf01f732d4@tarantool.org> <83e7df81-078c-def7-1f73-8810676bf241@tarantool.org> <6e626b42-dddd-5ac0-3e0f-f2b92d3ac8fe@tarantool.org> <35351452-fbd8-926f-886b-8210ccb8f74e@tarantool.org> <6e612f9a-b8bf-07fb-5964-f6cc7c8494c0@tarantool.org> Message-ID: <31ba9d2c-ea94-ba74-44b3-207d912dacca@tarantool.org> Date: Wed, 21 Apr 2021 08:59:19 +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: <6e612f9a-b8bf-07fb-5964-f6cc7c8494c0@tarantool.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: ru X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD92FFCB8E6708E7480257C85EA0BB7A95D0F00AE41BB9A5343182A05F538085040A9430493F4C5BEA80B17342BD1A79FF5E5FDC3924A8F97E60B66FE8C38A619BB X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE788A2BECDB72E1542EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637DD81BB19E5DE3F6B8638F802B75D45FF914D58D5BE9E6BC1A93B80C6DEB9DEE97C6FB206A91F05B24A9AA1EFEAEE36664F5ED13D495704BA8F4427C359EA06A0D2E47CDBA5A96583C09775C1D3CA48CF62968DCAA3E4B45B117882F4460429724CE54428C33FAD30A8DF7F3B2552694AC26CFBAC0749D213D2E47CDBA5A9658378DA827A17800CE7212612128AA291179FA2833FD35BB23DF004C90652538430302FCEF25BFAB3454AD6D5ED66289B5278DA827A17800CE7BB5BC2A87BE43590D32BA5DBAC0009BE395957E7521B51C20BC6067A898B09E4090A508E0FED6299176DF2183F8FC7C0B6C57F9B46A084A9CD04E86FAF290E2DA2C5D8508FA2CF601DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6753C3A5E0A5AB5B7089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2AD77751E876CB595E8F7B195E1C978310342C5F346BA9300A2A6A4873189992C X-C1DE0DAB: 0D63561A33F958A5661DC81A117C0B589149573D5DEA892C1B6132A3957C6281D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7502E6951B79FF9A3F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D346AD04FDA812EEFF15FC3533301646F718A9E341C294B893CF3E02B9C5252EE6F2BACA49B3E8287C91D7E09C32AA3244C986DC0298F3A2D14DB312891A31B2D85B018FE5BB746DCD1FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojlPRl29Bx4WEonwr0Mv0RrQ== X-Mailru-Sender: 583F1D7ACE8F49BDD2846D59FC20E9F8F7DA7E4D73C7A60E8B4A2FE8B752DF3186F1700BB67B7510424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v4 13/12] replication: send accumulated Raft messages after relay start 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" 21.04.2021 01:31, Vladislav Shpilevoy пишет: > Thanks for the patch! > > As discussed in private, there is a way to drop this flag, which I > did in a separate commit on top of this one, see below and on the > branch sp/gh-5445-election-fixes-review: Yes, thanks for reviewing this! Squashed. > ==================== > [tosquash] Remove flag do_restart_recovery > > diff --git a/src/box/relay.cc b/src/box/relay.cc > index 85f335cd7..ff43c2fc7 100644 > --- a/src/box/relay.cc > +++ b/src/box/relay.cc > @@ -95,7 +95,6 @@ struct relay_raft_msg { > struct cmsg_hop route[2]; > struct raft_request req; > struct vclock vclock; > - bool do_restart_recovery; > struct relay *relay; > }; > > @@ -433,6 +432,12 @@ relay_final_join(int fd, uint64_t sync, struct vclock *start_vclock, > relay_delete(relay); > }); > > + /* > + * Save the first vclock as 'received'. Because firstly, it was really > + * received. Secondly, recv_vclock is used by recovery restart and must > + * always be valid. > + */ > + vclock_copy(&relay->recv_vclock, start_vclock); > relay->r = recovery_new(wal_dir(), false, start_vclock); > vclock_copy(&relay->stop_vclock, stop_vclock); > > @@ -660,13 +665,12 @@ struct relay_is_raft_enabled_msg { > }; > > static void > -relay_push_raft_msg(struct relay *relay, bool do_restart_recovery) > +relay_push_raft_msg(struct relay *relay) > { > if (!relay->tx.is_raft_enabled || relay->tx.is_raft_push_sent) > return; > struct relay_raft_msg *msg = > &relay->tx.raft_msgs[relay->tx.raft_ready_msg]; > - msg->do_restart_recovery = do_restart_recovery; > cpipe_push(&relay->relay_pipe, &msg->base); > relay->tx.raft_ready_msg = (relay->tx.raft_ready_msg + 1) % 2; > relay->tx.is_raft_push_sent = true; > @@ -681,16 +685,9 @@ tx_set_is_raft_enabled(struct cmsg *base) > (struct relay_is_raft_enabled_msg *)base; > struct relay *relay = msg->relay; > relay->tx.is_raft_enabled = msg->value; > - /* > - * Send saved raft message as soon as relay becomes operational. > - * Do not restart recovery upon the message arrival. Recovery is > - * positioned at replica_clock initially, i.e. already "restarted" and > - * restarting it once again would position it at the oldest xlog > - * possible, because relay reader hasn't received replica vclock yet. > - */ > - if (relay->tx.is_raft_push_pending) { > - relay_push_raft_msg(msg->relay, false); > - } > + /* Send saved raft message as soon as relay becomes operational. */ > + if (relay->tx.is_raft_push_pending) > + relay_push_raft_msg(msg->relay); > } > > /** Relay thread part of the Raft flag setting, second hop. */ > @@ -901,6 +898,12 @@ relay_subscribe(struct replica *replica, int fd, uint64_t sync, > }); > > vclock_copy(&relay->local_vclock_at_subscribe, &replicaset.vclock); > + /* > + * Save the first vclock as 'received'. Because firstly, it was really > + * received. Secondly, recv_vclock is used by recovery restart and must > + * always be valid. > + */ > + vclock_copy(&relay->recv_vclock, replica_clock); > relay->r = recovery_new(wal_dir(), false, replica_clock); > vclock_copy(&relay->tx.vclock, replica_clock); > relay->version_id = replica_version_id; > @@ -1003,8 +1006,7 @@ relay_raft_msg_push(struct cmsg *base) > * would be ignored again. > */ > relay_send(msg->relay, &row); > - if (msg->req.state == RAFT_STATE_LEADER && > - msg->do_restart_recovery) > + if (msg->req.state == RAFT_STATE_LEADER) > relay_restart_recovery(msg->relay); > } catch (Exception *e) { > relay_set_error(msg->relay, e); > @@ -1018,7 +1020,7 @@ tx_raft_msg_return(struct cmsg *base) > struct relay_raft_msg *msg = (struct relay_raft_msg *)base; > msg->relay->tx.is_raft_push_sent = false; > if (msg->relay->tx.is_raft_push_pending) > - relay_push_raft_msg(msg->relay, true); > + relay_push_raft_msg(msg->relay); > } > > void > @@ -1042,7 +1044,7 @@ relay_push_raft(struct relay *relay, const struct raft_request *req) > cmsg_init(&msg->base, msg->route); > msg->relay = relay; > relay->tx.is_raft_push_pending = true; > - relay_push_raft_msg(relay, true); > + relay_push_raft_msg(relay); > } > > /** Send a single row to the client. */ -- Serge Petrenko