[Tarantool-patches] [PATCH 2/3] box/info: report replication.X.downstream.lag value
Serge Petrenko
sergepetrenko at tarantool.org
Wed Jan 27 14:56:52 MSK 2021
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 <gorcunov at gmail.com>
> ---
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
More information about the Tarantool-patches
mailing list