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 0D05870310; Wed, 27 Jan 2021 14:56:56 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 0D05870310 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1611748616; bh=nSFkEnVJNQpFgh1j4fXjoRHI4LbWIxzeO6T9imRB47M=; 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=P3JGmh6WJNClgFsyqCGXaczOk2jzzLGuv6D5Fr+k5dozsrg/bXMY4XZehdEjgpeSl 58QAVQMh9Hy+7JB+PlkZke4buXExA3blgcehCeNXlcGx7JmGCxr7n8S6qjthxjdebP p61KwStNVmvJSObMnqId0eYAwe4r736QkPHbE5D8= Received: from smtp44.i.mail.ru (smtp44.i.mail.ru [94.100.177.104]) (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 0923270310 for ; Wed, 27 Jan 2021 14:56:53 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 0923270310 Received: by smtp44.i.mail.ru with esmtpa (envelope-from ) id 1l4jRM-0005GY-Vw; Wed, 27 Jan 2021 14:56:53 +0300 To: Cyrill Gorcunov , tml Cc: Vladislav Shpilevoy References: <20210121171753.186891-1-gorcunov@gmail.com> <20210121171753.186891-3-gorcunov@gmail.com> Message-ID: <14c1c58c-0645-0262-e70d-3bf92aa88a49@tarantool.org> Date: Wed, 27 Jan 2021 14:56:52 +0300 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <20210121171753.186891-3-gorcunov@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD92BC6D7A73B5E1EC999351CFD198CD6A83B27540038C113F100894C459B0CD1B99B56C44D691749534CF07909B32523D9ED80BDE1649CFAE6FA2BE6A5C4945440 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7063907D3CC1FF486EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637222645A8BD7B05AE8638F802B75D45FF5571747095F342E8C7A0BC55FA0FE5FCC6B378509E50AFDB3985F7F6BDC99B906207D2443E45AA9C389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C0CB629EEF1311BF91D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8BAB5495298CADBD05A471835C12D1D977C4224003CC836476EB9C4185024447017B076A6E789B0E975F5C1EE8F4F765FC56BD83E4892B4D683AA81AA40904B5D9CF19DD082D7633A078D18283394535A93AA81AA40904B5D98AA50765F7900637A001AD3E0BB8BAD4D81D268191BDAD3D698AB9A7B718F8C442539A7722CA490C13377AFFFEAFD26923F8577A6DFFEA7CD79BF8A03098E3B193EC92FD9297F6715571747095F342E857739F23D657EF2BD5E8D9A59859A8B6936FEDF0B958011F089D37D7C0E48F6C5571747095F342E857739F23D657EF2B6825BDBE14D8E7028C9DFF55498CEFB0BD9CCCA9EDD067B1EDA766A37F9254B7 X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2BBE337FB72E92315FF39D8DB89857825EFA8BF88FCBFD63CE0852D54D1EC518141ACE6EBF280F5B3B832FCD551FADFD6 X-C1DE0DAB: 0D63561A33F958A53A688CA21A024300AAA5DF67659B25976C6D3828A156830DD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75F04B387B5D7535DE410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3454CC76E5F54B410C507133FBEFBF59BE42EC558CB92C8313BEC18A0323E99DA9D6AB7B35C8E99B221D7E09C32AA3244CADA8756DCA7A3641F0BC085C8A7AE2DFE8FBBEFAE1C4874CFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj5ZUBkD5pAd+eyewyV5/GoQ== X-Mailru-Sender: 583F1D7ACE8F49BDF28A51E06CB90EC1E07FC15BCCE8C7BB09DCFEC2219958E38BD78E3F498279BA823C4E0A9438D55D74690CA6451351EDEC462FDC9CAD1E11B969B486931C0B990F27244EEAA5B9A5AE208404248635DF X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH 2/3] box/info: report replication.X.downstream.lag value 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.01.2021 20:17, Cyrill Gorcunov пишет: > This is basically a reflection of replication.X.upstream.lag value. > The upstream lag can be considered as transaction RTT in direction > from master to replica, in turn downstream lag is the reverse and > represents RTT from replica to master. > > An example of output is (on replica node) > > | 2: > | id: 2 > | uuid: 8bb22366-cd21-492e-98df-693884be11bd > | lsn: 0 > | downstream: > | status: follow > | idle: 0.55381065199617 > | vclock: {1: 119} > | lag: 0.00019168853759766 > > In case if there some old replicas which are not sending > timestamp in vclock encoding we simply don't show lag > field for backward compatibility sake. > > Closes #5447 > > Signed-off-by: Cyrill Gorcunov > --- Hi! Thanks for the patch! Please see a couple of nits below. > src/box/lua/info.c | 9 ++++++++- > src/box/relay.cc | 17 +++++++++++++++++ > src/box/relay.h | 8 ++++++++ > 3 files changed, 33 insertions(+), 1 deletion(-) > > diff --git a/src/box/lua/info.c b/src/box/lua/info.c > index c4c9fa0a0..b36c2e6f4 100644 > --- a/src/box/lua/info.c > +++ b/src/box/lua/info.c > @@ -132,17 +132,24 @@ lbox_pushrelay(lua_State *L, struct relay *relay) > lua_pushstring(L, "status"); > > switch(relay_get_state(relay)) { > - case RELAY_FOLLOW: > + case RELAY_FOLLOW: { The brace should go on a new line. > + double lag = relay_lag(relay); > lua_pushstring(L, "follow"); > lua_settable(L, -3); > lua_pushstring(L, "vclock"); > lbox_pushvclock(L, relay_vclock(relay)); > lua_settable(L, -3); > + if (lag != 0) { > + lua_pushstring(L, "lag"); > + lua_pushnumber(L, relay_lag(relay)); > + lua_settable(L, -3); > + } > lua_pushstring(L, "idle"); > lua_pushnumber(L, ev_monotonic_now(loop()) - > relay_last_row_time(relay)); > lua_settable(L, -3); > break; > + } > case RELAY_STOPPED: > { > lua_pushstring(L, "stopped"); > @@ -558,6 +568,13 @@ 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); > + /* > + * Old versions may send not a timestamp but > + * zeroified memory field. We can use +0 as > + * as sign that there is nothing encoded. typo: as a sign. > + */ > + if (xrow.tm != 0) > + relay->lag = ev_now(loop()) - xrow.tm; > fiber_cond_signal(&relay->reader_cond); > } > } catch (Exception *e) { > diff --git a/src/box/relay.h b/src/box/relay.h > index b32e2ea2a..ec9d16925 100644 > --- a/src/box/relay.h > +++ b/src/box/relay.h > @@ -93,6 +93,14 @@ relay_vclock(const struct relay *relay); > double > relay_last_row_time(const struct relay *relay); > > +/** > + * Returns relay's lag > + * @param relay relay > + * @returns relay's lag > + */ > +double > +relay_lag(const struct relay *relay); > + > /** > * Send a Raft update request to the relay channel. It is not > * guaranteed that it will be delivered. The connection may break. -- Serge Petrenko