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 226C16EC40; Tue, 8 Jun 2021 21:15:12 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 226C16EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1623176112; bh=vV9Fw7RX1yXjBveSbM067dLEuvdnO8mX/Qsm5LgOnm0=; 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=v2Kq50gUQLsS71frQH6tzyOaIt9QzqsNb3kfTgrOOl0pM7xY4JWLHBydVZ5a2DBD0 9cVW6036yEFLkE4LLye5bQsZzAojrDNtsQb3aRsg0gexOT8aQK7mzIKbeo1d2rHOeG K7nv5MZlJPqjAKRIAx6wqNz/yC+rFEBrGQffEErg= Received: from smtp55.i.mail.ru (smtp55.i.mail.ru [217.69.128.35]) (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 7D52D6EC40 for ; Tue, 8 Jun 2021 21:15:11 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 7D52D6EC40 Received: by smtp55.i.mail.ru with esmtpa (envelope-from ) id 1lqgFq-0007tX-Qy; Tue, 08 Jun 2021 21:15:11 +0300 To: Cyrill Gorcunov Cc: tml References: <20210607155519.109626-1-gorcunov@gmail.com> <20210607155519.109626-3-gorcunov@gmail.com> Message-ID: <3a0cf108-090f-e29c-b168-d00d3266fc7d@tarantool.org> Date: Tue, 8 Jun 2021 20:15:09 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9D5B0DA836B685C543EF5F9E25E4001B3518B676B8BE4A4C7182A05F538085040ABC6BB393AB75C14DF97D4A915BD620837DB27182A3C5264142629AA6E676547 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7BB17EE3498E810FEEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637204D59D994DFFAD78638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8ECCB05F8154D0FA3DB1D6AA103F0D83F117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC974A882099E279BDA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735201E561CDFBCA1751FBDFBBEFFF4125B51D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EECCD848CCB6FE560CE21AE983DBD7FFC1D8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE317119E5299B287EE040F9FF01DFDA4A8C4224003CC836476EA7A3FFF5B025636E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637AD0424077D726551EFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2368A440D3B0F6089093C9A16E5BC824A2A04A2ABAA09D25379311020FFC8D4ADBDCD2FAD7D06D3B468A4BC11AE862C96 X-C1DE0DAB: 0D63561A33F958A552F54A83D7D76B9F34286CCE2508980BBD037E5CF4BC19A9D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75FBC5FED0552DA851410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D347215713CF3EEE9D133C1B6D9F51370031F11AD846C29EBFF6AB70449C5CDAA92048402893C29EDDA1D7E09C32AA3244C1506BFEA6ED2FECCA607E3747F52B8D3D08D48398F32B4A6729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojvdTwgM2ZyZnHeIFEYEM5kQ== X-Mailru-Sender: 504CC1E875BF3E7D9BC0E5172ADA311020B3B392CD1B527CDFB2936E78D62894D74A6C029A5A33EC07784C02288277CA03E0582D3806FB6A5317862B1921BA260ED6CFD6382C13A6112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v8 2/2] relay: provide information about downstream lag 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: Vladislav Shpilevoy via Tarantool-patches Reply-To: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" On 08.06.2021 10:40, Cyrill Gorcunov wrote: > On Mon, Jun 07, 2021 at 09:21:09PM +0200, Vladislav Shpilevoy wrote: >>> >>> +double >>> +relay_txn_lag(const struct relay *relay) >>> +{ >>> + return relay->txn_lag; >> >> 1. As I said in the previous review, you can't read a variable from another >> thread without any protection. > > Let me explain why I did so - I really don't like that we have to add another > variable into relay structure: we already have the lag keeper in replica > structure and since the lag value is not any kind of sync point or some flag > the value of which changes program flow logic, we can use parallel read from > another thread. Moreover we could use guaranteed atomic read operation, at > least on x86 (via return *(int64_t *)relay->txn_lag, though we must be sure > the member is qword aligned). It is not only x86 anymore. Any assumptions, on which the data correctness depends, must not be made. >>> @@ -629,6 +659,26 @@ relay_reader_f(va_list ap) >>> /* vclock is followed while decoding, zeroing it. */ >>> vclock_create(&relay->recv_vclock); >>> xrow_decode_vclock_xc(&xrow, &relay->recv_vclock); >>> + /* >>> + * Replica send us last replicated transaction >>> + * timestamp which is needed for relay lag >>> + * monitoring. Note that this transaction has >>> + * been written to WAL with our current realtime >>> + * clock value, thus when it get reported back we >>> + * can compute time spent regardless of the clock >>> + * value on remote replica. >>> + * >>> + * An interesting moment is replica restart - it will >>> + * send us value 0 after that but we can preserve >>> + * old reported value here since we *assume* that >>> + * timestamp is not going backwards on properly >>> + * set up nodes, otherwise the lag get raised. >>> + * After all this is a not tamper-proof value. >> >> 2. I don't understand. Why does it send value 0? And if it does, why >> can't you ignore only zeros? The non-0 values must be valid anyway. > > IOW, the real situation is the following: > > - if replica restarted, but main node is alive, the lag report on the > main node is dropped to 0 > > - if main node get restarted, then lag report is dropped to 0 as well > > I suppose this is expected? I'll update the comment above. Drop to 0 in case of any reconnect until data is being replicated again is fine. >>> +++ b/test/replication/gh-5447-downstream-lag.result >>> @@ -0,0 +1,93 @@ >>> +-- test-run result file version 2 >>> +-- >>> +-- gh-5447: Test for box.info.replication[n].downstream.lag. >>> +-- We need to be sure that if replica start been back of >>> +-- master node reports own lagging and cluster admin would >>> +-- be able to detect such situation. >> >> 3. I couldn't parse the last sentence. Could you use some >> punctuation? It might help. > > Would the following be better? "We need to be sure that slow > ACKs delivery might be catched by monitoring tools". Yes. Except 'catched' -> 'caught'. >>> + >>> +-- >>> +-- The replica should wait some time (wal delay is 1 second >>> +-- by default) so we would be able to detect the lag, since >>> +-- on local instances the lag is minimal and usually transactions >>> +-- are handled instantly. >> >> 4. But it is not 1 second. usleep(1000) means 1 millisecond, and it > > No, usleep(1000) means exactly 1 second, this system call works with > microseconds, I think you misread it with nanosleep(). 1 second has 1 000 000 microseconds. 1000us is 1ms. Not 1s. >> happens in a loop, so it does not matter much. It works until you >> set the delay back to false. That makes WAL thread blocked until >> you free it. It is not a fixed delay. > > Not sure I follow you here. We force wal engine to slow down _each_ > write to take at least 1 second long, in turn this will delay the > ACK delivery and calculated lag won't be zero. No, this is not how it works. When you turn on the delay, you block the WAL thread from doing anything. It is not a delay per transaction. Please, open ERROR_INJECT_SLEEP() (which is used for ERRINJ_WAL_DELAY) and see how it works. I paste it below. # define ERROR_INJECT_WHILE(ID, CODE) \ do { \ while (errinj(ID, ERRINJ_BOOL)->bparam) \ CODE; \ } while (0) It is a busy loop until you drop the injection back to false.