Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH 0/3] box/info: report replication.X.downstream.lag
@ 2021-01-21 17:17 Cyrill Gorcunov via Tarantool-patches
  2021-01-21 17:17 ` [Tarantool-patches] [PATCH 1/3] xrow: encode timestamp into vclock message Cyrill Gorcunov via Tarantool-patches
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Cyrill Gorcunov via Tarantool-patches @ 2021-01-21 17:17 UTC (permalink / raw)
  To: tml; +Cc: Vladislav Shpilevoy

In the series we add reporting replication.X.downstream.lag value
to complement replication.X.upstream.lag.

Note that this value represent exact counter part of upstream.lag
since detailed statistics about qsync and synchronous acks has
a different meaning and gonna be implemented in #5191.

Please take a look once time permit. As far as I can tell we
can safely start encoding timestamp into vclock message without
affecting any old instances. I've grepped the 1.10.x series
for potential problems and didn't find any sign of.

issue https://github.com/tarantool/tarantool/issues/5447
branch gorcunov/gh-5447-relay-lag

Cyrill Gorcunov (3):
  xrow: encode timestamp into vclock message
  box/info: report replication.X.downstream.lag value
  test: replication/status -- fetch downstream lag field

 src/box/lua/info.c               |  9 ++++++++-
 src/box/relay.cc                 | 17 +++++++++++++++++
 src/box/relay.h                  |  8 ++++++++
 src/box/xrow.c                   |  1 +
 test/replication/status.result   |  8 ++++++++
 test/replication/status.test.lua |  6 ++++++
 6 files changed, 48 insertions(+), 1 deletion(-)


base-commit: fc86213cd7cda0641df95b1a81949bab85c19fce
-- 
2.29.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Tarantool-patches] [PATCH 1/3] xrow: encode timestamp into vclock message
  2021-01-21 17:17 [Tarantool-patches] [PATCH 0/3] box/info: report replication.X.downstream.lag Cyrill Gorcunov via Tarantool-patches
@ 2021-01-21 17:17 ` Cyrill Gorcunov via Tarantool-patches
  2021-01-31 17:43   ` Vladislav Shpilevoy via Tarantool-patches
  2021-01-21 17:17 ` [Tarantool-patches] [PATCH 2/3] box/info: report replication.X.downstream.lag value Cyrill Gorcunov via Tarantool-patches
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 14+ messages in thread
From: Cyrill Gorcunov via Tarantool-patches @ 2021-01-21 17:17 UTC (permalink / raw)
  To: tml; +Cc: Vladislav Shpilevoy

The vclock message sent by "applierw" fiber to the replication
master node operates not only for tracking status of applied data
but also as a heartbeat packets (after 1.7.7).

The timestamp field of the xrow_header left zero here we can reuse
it to track downstream node state by putting realtime value here.
This won't break any existing instances without the patch because
the field is unused anywhere yet.

Need to mention that xrow_encode_vclock used for other stages
such as joining and encoding realtime value here won't hurt
as well.

Part-of #5447

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 src/box/xrow.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/box/xrow.c b/src/box/xrow.c
index bc06738ad..1a077fafd 100644
--- a/src/box/xrow.c
+++ b/src/box/xrow.c
@@ -1648,6 +1648,7 @@ xrow_encode_vclock(struct xrow_header *row, const struct vclock *vclock)
 	row->body[0].iov_base = buf;
 	row->body[0].iov_len = (data - buf);
 	row->bodycnt = 1;
+	row->tm = ev_now(loop());
 	row->type = IPROTO_OK;
 	return 0;
 }
-- 
2.29.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Tarantool-patches] [PATCH 2/3] box/info: report replication.X.downstream.lag value
  2021-01-21 17:17 [Tarantool-patches] [PATCH 0/3] box/info: report replication.X.downstream.lag Cyrill Gorcunov via Tarantool-patches
  2021-01-21 17:17 ` [Tarantool-patches] [PATCH 1/3] xrow: encode timestamp into vclock message Cyrill Gorcunov via Tarantool-patches
@ 2021-01-21 17:17 ` Cyrill Gorcunov via Tarantool-patches
  2021-01-27 11:56   ` Serge Petrenko via Tarantool-patches
  2021-01-31 17:45   ` Vladislav Shpilevoy via Tarantool-patches
  2021-01-21 17:17 ` [Tarantool-patches] [PATCH 3/3] test: replication/status -- fetch downstream lag field Cyrill Gorcunov via Tarantool-patches
  2021-01-21 17:17 ` Cyrill Gorcunov via Tarantool-patches
  3 siblings, 2 replies; 14+ messages in thread
From: Cyrill Gorcunov via Tarantool-patches @ 2021-01-21 17:17 UTC (permalink / raw)
  To: tml; +Cc: Vladislav Shpilevoy

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@gmail.com>
---
 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: {
+		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");
diff --git a/src/box/relay.cc b/src/box/relay.cc
index df04f8198..9265a26b3 100644
--- a/src/box/relay.cc
+++ b/src/box/relay.cc
@@ -138,6 +138,8 @@ struct relay {
 	struct stailq pending_gc;
 	/** Time when last row was sent to peer. */
 	double last_row_time;
+	/** Number of seconds this master is prior the remote replica. */
+	double lag;
 	/** Relay sync state. */
 	enum relay_state state;
 
@@ -179,6 +181,12 @@ relay_last_row_time(const struct relay *relay)
 	return relay->last_row_time;
 }
 
+double
+relay_lag(const struct relay *relay)
+{
+	return relay->lag;
+}
+
 static void
 relay_send(struct relay *relay, struct xrow_header *packet);
 static void
@@ -197,6 +205,7 @@ relay_new(struct replica *replica)
 	}
 	relay->replica = replica;
 	relay->last_row_time = ev_monotonic_now(loop());
+	relay->lag = 0;
 	fiber_cond_create(&relay->reader_cond);
 	diag_create(&relay->diag);
 	stailq_create(&relay->pending_gc);
@@ -219,6 +228,7 @@ relay_start(struct relay *relay, int fd, uint64_t sync,
 	relay->sync = sync;
 	relay->state = RELAY_FOLLOW;
 	relay->last_row_time = ev_monotonic_now(loop());
+	relay->lag = 0;
 }
 
 void
@@ -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.
+			 */
+			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.
-- 
2.29.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Tarantool-patches] [PATCH 3/3] test: replication/status -- fetch downstream lag field
  2021-01-21 17:17 [Tarantool-patches] [PATCH 0/3] box/info: report replication.X.downstream.lag Cyrill Gorcunov via Tarantool-patches
  2021-01-21 17:17 ` [Tarantool-patches] [PATCH 1/3] xrow: encode timestamp into vclock message Cyrill Gorcunov via Tarantool-patches
  2021-01-21 17:17 ` [Tarantool-patches] [PATCH 2/3] box/info: report replication.X.downstream.lag value Cyrill Gorcunov via Tarantool-patches
@ 2021-01-21 17:17 ` Cyrill Gorcunov via Tarantool-patches
  2021-01-31 17:46   ` Vladislav Shpilevoy via Tarantool-patches
  2021-01-21 17:17 ` Cyrill Gorcunov via Tarantool-patches
  3 siblings, 1 reply; 14+ messages in thread
From: Cyrill Gorcunov via Tarantool-patches @ 2021-01-21 17:17 UTC (permalink / raw)
  To: tml; +Cc: Vladislav Shpilevoy

Extend the test to observe downstream.lag value.

Part-of #5447

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 test/replication/status.result   | 8 ++++++++
 test/replication/status.test.lua | 6 ++++++
 2 files changed, 14 insertions(+)

diff --git a/test/replication/status.result b/test/replication/status.result
index a8c515dbb..e59694730 100644
--- a/test/replication/status.result
+++ b/test/replication/status.result
@@ -186,6 +186,14 @@ test_run:wait_cond(function()                    \
 ---
 - true
 ...
+-- once replication vclock is reached there
+-- should be non infinity downstream lag, set
+-- it to some sane value but not short since
+-- there might be network lags on a low level
+replica.downstream.lag ~= nil and replica.downstream.lag < 60
+---
+- true
+...
 --
 -- Replica
 --
diff --git a/test/replication/status.test.lua b/test/replication/status.test.lua
index 431463d8a..0525694bb 100644
--- a/test/replication/status.test.lua
+++ b/test/replication/status.test.lua
@@ -73,6 +73,12 @@ test_run:wait_cond(function()                    \
             r[replica_id] == box.info.vclock[replica_id]) \
     end) or require('log').error(box.info)
 
+-- once replication vclock is reached there
+-- should be non infinity downstream lag, set
+-- it to some sane value but not short since
+-- there might be network lags on a low level
+replica.downstream.lag ~= nil and replica.downstream.lag < 60
+
 --
 -- Replica
 --
-- 
2.29.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Tarantool-patches] [PATCH 3/3] test: replication/status -- fetch downstream lag field
  2021-01-21 17:17 [Tarantool-patches] [PATCH 0/3] box/info: report replication.X.downstream.lag Cyrill Gorcunov via Tarantool-patches
                   ` (2 preceding siblings ...)
  2021-01-21 17:17 ` [Tarantool-patches] [PATCH 3/3] test: replication/status -- fetch downstream lag field Cyrill Gorcunov via Tarantool-patches
@ 2021-01-21 17:17 ` Cyrill Gorcunov via Tarantool-patches
  2021-01-21 17:23   ` Cyrill Gorcunov via Tarantool-patches
  3 siblings, 1 reply; 14+ messages in thread
From: Cyrill Gorcunov via Tarantool-patches @ 2021-01-21 17:17 UTC (permalink / raw)
  To: tml; +Cc: Vladislav Shpilevoy

Extend the test to observe downstream.lag value.

Part-of #5447

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 test/replication/status.result   | 8 ++++++++
 test/replication/status.test.lua | 6 ++++++
 2 files changed, 14 insertions(+)

diff --git a/test/replication/status.result b/test/replication/status.result
index a8c515dbb..e59694730 100644
--- a/test/replication/status.result
+++ b/test/replication/status.result
@@ -186,6 +186,14 @@ test_run:wait_cond(function()                    \
 ---
 - true
 ...
+-- once replication vclock is reached there
+-- should be non infinity downstream lag, set
+-- it to some sane value but not short since
+-- there might be network lags on a low level
+replica.downstream.lag ~= nil and replica.downstream.lag < 60
+---
+- true
+...
 --
 -- Replica
 --
diff --git a/test/replication/status.test.lua b/test/replication/status.test.lua
index 431463d8a..0525694bb 100644
--- a/test/replication/status.test.lua
+++ b/test/replication/status.test.lua
@@ -73,6 +73,12 @@ test_run:wait_cond(function()                    \
             r[replica_id] == box.info.vclock[replica_id]) \
     end) or require('log').error(box.info)
 
+-- once replication vclock is reached there
+-- should be non infinity downstream lag, set
+-- it to some sane value but not short since
+-- there might be network lags on a low level
+replica.downstream.lag ~= nil and replica.downstream.lag < 60
+
 --
 -- Replica
 --
-- 
2.29.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Tarantool-patches] [PATCH 3/3] test: replication/status -- fetch downstream lag field
  2021-01-21 17:17 ` Cyrill Gorcunov via Tarantool-patches
@ 2021-01-21 17:23   ` Cyrill Gorcunov via Tarantool-patches
  0 siblings, 0 replies; 14+ messages in thread
From: Cyrill Gorcunov via Tarantool-patches @ 2021-01-21 17:23 UTC (permalink / raw)
  To: tml; +Cc: Vladislav Shpilevoy

On Thu, Jan 21, 2021 at 08:17:53PM +0300, Cyrill Gorcunov wrote:
> Extend the test to observe downstream.lag value.
> 

Ignore this duplicate please, didn't clean messages directory from
dups before sending, sorry.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Tarantool-patches] [PATCH 2/3] box/info: report replication.X.downstream.lag value
  2021-01-21 17:17 ` [Tarantool-patches] [PATCH 2/3] box/info: report replication.X.downstream.lag value Cyrill Gorcunov via Tarantool-patches
@ 2021-01-27 11:56   ` Serge Petrenko via Tarantool-patches
  2021-01-27 12:12     ` Cyrill Gorcunov via Tarantool-patches
  2021-01-31 17:45   ` Vladislav Shpilevoy via Tarantool-patches
  1 sibling, 1 reply; 14+ messages in thread
From: Serge Petrenko via Tarantool-patches @ 2021-01-27 11:56 UTC (permalink / raw)
  To: Cyrill Gorcunov, tml; +Cc: Vladislav Shpilevoy



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@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


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Tarantool-patches] [PATCH 2/3] box/info: report replication.X.downstream.lag value
  2021-01-27 11:56   ` Serge Petrenko via Tarantool-patches
@ 2021-01-27 12:12     ` Cyrill Gorcunov via Tarantool-patches
  2021-01-27 14:04       ` Serge Petrenko via Tarantool-patches
  0 siblings, 1 reply; 14+ messages in thread
From: Cyrill Gorcunov via Tarantool-patches @ 2021-01-27 12:12 UTC (permalink / raw)
  To: Serge Petrenko; +Cc: tml, Vladislav Shpilevoy

On Wed, Jan 27, 2021 at 02:56:52PM +0300, Serge Petrenko wrote:
> >   	switch(relay_get_state(relay)) {
> > -	case RELAY_FOLLOW:
> > +	case RELAY_FOLLOW: {
> 
> The brace should go on a new line.

OK

> > @@ -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.

Thanks! Force pushed an update
---
 src/box/lua/info.c | 3 ++-
 src/box/relay.cc   | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/box/lua/info.c b/src/box/lua/info.c
index b36c2e6f4..1e533fe8d 100644
--- a/src/box/lua/info.c
+++ b/src/box/lua/info.c
@@ -132,7 +132,8 @@ lbox_pushrelay(lua_State *L, struct relay *relay)
 	lua_pushstring(L, "status");
 
 	switch(relay_get_state(relay)) {
-	case RELAY_FOLLOW: {
+	case RELAY_FOLLOW:
+	{
 		double lag = relay_lag(relay);
 		lua_pushstring(L, "follow");
 		lua_settable(L, -3);
diff --git a/src/box/relay.cc b/src/box/relay.cc
index 9265a26b3..a486db23a 100644
--- a/src/box/relay.cc
+++ b/src/box/relay.cc
@@ -571,7 +571,7 @@ relay_reader_f(va_list ap)
 			/*
 			 * Old versions may send not a timestamp but
 			 * zeroified memory field. We can use +0 as
-			 * as sign that there is nothing encoded.
+			 * as a sign that there is nothing encoded.
 			 */
 			if (xrow.tm != 0)
 				relay->lag = ev_now(loop()) - xrow.tm;
-- 
2.29.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Tarantool-patches] [PATCH 2/3] box/info: report replication.X.downstream.lag value
  2021-01-27 12:12     ` Cyrill Gorcunov via Tarantool-patches
@ 2021-01-27 14:04       ` Serge Petrenko via Tarantool-patches
  2021-01-27 14:38         ` Cyrill Gorcunov via Tarantool-patches
  0 siblings, 1 reply; 14+ messages in thread
From: Serge Petrenko via Tarantool-patches @ 2021-01-27 14:04 UTC (permalink / raw)
  To: Cyrill Gorcunov; +Cc: tml, Vladislav Shpilevoy



27.01.2021 15:12, Cyrill Gorcunov пишет:
> On Wed, Jan 27, 2021 at 02:56:52PM +0300, Serge Petrenko wrote:
>>>    	switch(relay_get_state(relay)) {
>>> -	case RELAY_FOLLOW:
>>> +	case RELAY_FOLLOW: {
>> The brace should go on a new line.
> OK
>
>>> @@ -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.
> Thanks! Force pushed an update

Thanks for the fixes!

> ---
>   src/box/lua/info.c | 3 ++-
>   src/box/relay.cc   | 2 +-
>   2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/src/box/lua/info.c b/src/box/lua/info.c
> index b36c2e6f4..1e533fe8d 100644
> --- a/src/box/lua/info.c
> +++ b/src/box/lua/info.c
> @@ -132,7 +132,8 @@ lbox_pushrelay(lua_State *L, struct relay *relay)
>   	lua_pushstring(L, "status");
>   
>   	switch(relay_get_state(relay)) {
> -	case RELAY_FOLLOW: {
> +	case RELAY_FOLLOW:
> +	{
>   		double lag = relay_lag(relay);
>   		lua_pushstring(L, "follow");
>   		lua_settable(L, -3);
> diff --git a/src/box/relay.cc b/src/box/relay.cc
> index 9265a26b3..a486db23a 100644
> --- a/src/box/relay.cc
> +++ b/src/box/relay.cc
> @@ -571,7 +571,7 @@ relay_reader_f(va_list ap)
>   			/*
>   			 * Old versions may send not a timestamp but
>   			 * zeroified memory field. We can use +0 as
> -			 * as sign that there is nothing encoded.
> +			 * as a sign that there is nothing encoded.

Now there's double "as". Look at the previous line. =)

>   			 */
>   			if (xrow.tm != 0)
>   				relay->lag = ev_now(loop()) - xrow.tm;

-- 
Serge Petrenko


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Tarantool-patches] [PATCH 2/3] box/info: report replication.X.downstream.lag value
  2021-01-27 14:04       ` Serge Petrenko via Tarantool-patches
@ 2021-01-27 14:38         ` Cyrill Gorcunov via Tarantool-patches
  2021-01-27 14:44           ` Serge Petrenko via Tarantool-patches
  0 siblings, 1 reply; 14+ messages in thread
From: Cyrill Gorcunov via Tarantool-patches @ 2021-01-27 14:38 UTC (permalink / raw)
  To: Serge Petrenko; +Cc: tml, Vladislav Shpilevoy

On Wed, Jan 27, 2021 at 05:04:27PM +0300, Serge Petrenko wrote:
> > diff --git a/src/box/relay.cc b/src/box/relay.cc
> > index 9265a26b3..a486db23a 100644
> > --- a/src/box/relay.cc
> > +++ b/src/box/relay.cc
> > @@ -571,7 +571,7 @@ relay_reader_f(va_list ap)
> >   			/*
> >   			 * Old versions may send not a timestamp but
> >   			 * zeroified memory field. We can use +0 as
> > -			 * as sign that there is nothing encoded.
> > +			 * as a sign that there is nothing encoded.
> 
> Now there's double "as". Look at the previous line. =)

Heh :) Thanks! Pushed an update.
---
[cyrill@grain tarantool.git] git diff
diff --git a/src/box/relay.cc b/src/box/relay.cc
index a486db23a..859069a7b 100644
--- a/src/box/relay.cc
+++ b/src/box/relay.cc
@@ -571,7 +571,7 @@ relay_reader_f(va_list ap)
                        /*
                         * Old versions may send not a timestamp but
                         * zeroified memory field. We can use +0 as
-                        * as a sign that there is nothing encoded.
+                        * a sign that there is nothing encoded.
                         */
                        if (xrow.tm != 0)
                                relay->lag = ev_now(loop()) - xrow.tm;


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Tarantool-patches] [PATCH 2/3] box/info: report replication.X.downstream.lag value
  2021-01-27 14:38         ` Cyrill Gorcunov via Tarantool-patches
@ 2021-01-27 14:44           ` Serge Petrenko via Tarantool-patches
  0 siblings, 0 replies; 14+ messages in thread
From: Serge Petrenko via Tarantool-patches @ 2021-01-27 14:44 UTC (permalink / raw)
  To: Cyrill Gorcunov; +Cc: tml, Vladislav Shpilevoy



27.01.2021 17:38, Cyrill Gorcunov пишет:
> On Wed, Jan 27, 2021 at 05:04:27PM +0300, Serge Petrenko wrote:
>>> diff --git a/src/box/relay.cc b/src/box/relay.cc
>>> index 9265a26b3..a486db23a 100644
>>> --- a/src/box/relay.cc
>>> +++ b/src/box/relay.cc
>>> @@ -571,7 +571,7 @@ relay_reader_f(va_list ap)
>>>    			/*
>>>    			 * Old versions may send not a timestamp but
>>>    			 * zeroified memory field. We can use +0 as
>>> -			 * as sign that there is nothing encoded.
>>> +			 * as a sign that there is nothing encoded.
>> Now there's double "as". Look at the previous line. =)
> Heh :) Thanks! Pushed an update.
> ---
> [cyrill@grain tarantool.git] git diff
> diff --git a/src/box/relay.cc b/src/box/relay.cc
> index a486db23a..859069a7b 100644
> --- a/src/box/relay.cc
> +++ b/src/box/relay.cc
> @@ -571,7 +571,7 @@ relay_reader_f(va_list ap)
>                          /*
>                           * Old versions may send not a timestamp but
>                           * zeroified memory field. We can use +0 as
> -                        * as a sign that there is nothing encoded.
> +                        * a sign that there is nothing encoded.
>                           */
>                          if (xrow.tm != 0)
>                                  relay->lag = ev_now(loop()) - xrow.tm;
>

LGTM.

-- 
Serge Petrenko


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Tarantool-patches] [PATCH 1/3] xrow: encode timestamp into vclock message
  2021-01-21 17:17 ` [Tarantool-patches] [PATCH 1/3] xrow: encode timestamp into vclock message Cyrill Gorcunov via Tarantool-patches
@ 2021-01-31 17:43   ` Vladislav Shpilevoy via Tarantool-patches
  0 siblings, 0 replies; 14+ messages in thread
From: Vladislav Shpilevoy via Tarantool-patches @ 2021-01-31 17:43 UTC (permalink / raw)
  To: Cyrill Gorcunov, tml

Hi! Thanks for the patch!

On 21.01.2021 18:17, Cyrill Gorcunov via Tarantool-patches wrote:
> The vclock message sent by "applierw" fiber to the replication
> master node operates not only for tracking status of applied data
> but also as a heartbeat packets (after 1.7.7).
> 
> The timestamp field of the xrow_header left zero here we can reuse
> it to track downstream node state by putting realtime value here.
> This won't break any existing instances without the patch because
> the field is unused anywhere yet.
> 
> Need to mention that xrow_encode_vclock used for other stages
> such as joining and encoding realtime value here won't hurt
> as well.

"Won't hurt" is not a good justification for adding a new field
to all vclocks we send everywhere. As well as it is not good to
add libev dependency to xrow internals. Better avoid adding something
"just in case". We need tm in applier heartbeats - lets add them to
there and only there.

You need tm in a single place - in applier_writer_f(), is it
correct? Just add a new function: xrow_encode_vclock_timed()
or something like this. It would take a timestamp. Like
xrow_encode_timestamp() does.

The old xrow_encode_vclock() would call xrow_encode_vclock_timed()
with 0 time, so there won't even be any code duplication.

> Part-of #5447
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
> ---
>  src/box/xrow.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/src/box/xrow.c b/src/box/xrow.c
> index bc06738ad..1a077fafd 100644
> --- a/src/box/xrow.c
> +++ b/src/box/xrow.c
> @@ -1648,6 +1648,7 @@ xrow_encode_vclock(struct xrow_header *row, const struct vclock *vclock)
>  	row->body[0].iov_base = buf;
>  	row->body[0].iov_len = (data - buf);
>  	row->bodycnt = 1;
> +	row->tm = ev_now(loop());
>  	row->type = IPROTO_OK;
>  	return 0;
>  }
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Tarantool-patches] [PATCH 2/3] box/info: report replication.X.downstream.lag value
  2021-01-21 17:17 ` [Tarantool-patches] [PATCH 2/3] box/info: report replication.X.downstream.lag value Cyrill Gorcunov via Tarantool-patches
  2021-01-27 11:56   ` Serge Petrenko via Tarantool-patches
@ 2021-01-31 17:45   ` Vladislav Shpilevoy via Tarantool-patches
  1 sibling, 0 replies; 14+ messages in thread
From: Vladislav Shpilevoy via Tarantool-patches @ 2021-01-31 17:45 UTC (permalink / raw)
  To: Cyrill Gorcunov, tml

Thanks for the patch!

It seems upstream.lag is documented. I suggest to document
downstream.lag too.

https://www.tarantool.io/en/doc/latest/book/replication/repl_monitoring/

> diff --git a/src/box/relay.cc b/src/box/relay.cc
> index df04f8198..9265a26b3 100644
> --- a/src/box/relay.cc
> +++ b/src/box/relay.cc
> @@ -197,6 +205,7 @@ relay_new(struct replica *replica)
>  	}
>  	relay->replica = replica;
>  	relay->last_row_time = ev_monotonic_now(loop());
> +	relay->lag = 0;

It is allocated with 'calloc', you don't need to nullify
anything.

>  	fiber_cond_create(&relay->reader_cond);
>  	diag_create(&relay->diag);
>  	stailq_create(&relay->pending_gc);

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Tarantool-patches] [PATCH 3/3] test: replication/status -- fetch downstream lag field
  2021-01-21 17:17 ` [Tarantool-patches] [PATCH 3/3] test: replication/status -- fetch downstream lag field Cyrill Gorcunov via Tarantool-patches
@ 2021-01-31 17:46   ` Vladislav Shpilevoy via Tarantool-patches
  0 siblings, 0 replies; 14+ messages in thread
From: Vladislav Shpilevoy via Tarantool-patches @ 2021-01-31 17:46 UTC (permalink / raw)
  To: Cyrill Gorcunov, tml

Thanks for the patch!

> diff --git a/test/replication/status.result b/test/replication/status.result
> index a8c515dbb..e59694730 100644
> --- a/test/replication/status.result
> +++ b/test/replication/status.result
> @@ -186,6 +186,14 @@ test_run:wait_cond(function()                    \
>  ---
>  - true
>  ...
> +-- once replication vclock is reached there
> +-- should be non infinity downstream lag, set
> +-- it to some sane value but not short since
> +-- there might be network lags on a low level

At least in the tests try to start sentences with a capital
letter and end them with a period. Also for tests related to a
ticket we add 'gh-####: ` to the beginning of the comment.

> +replica.downstream.lag ~= nil and replica.downstream.lag < 60
> +---
> +- true
> +...

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-01-31 17:46 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-21 17:17 [Tarantool-patches] [PATCH 0/3] box/info: report replication.X.downstream.lag Cyrill Gorcunov via Tarantool-patches
2021-01-21 17:17 ` [Tarantool-patches] [PATCH 1/3] xrow: encode timestamp into vclock message Cyrill Gorcunov via Tarantool-patches
2021-01-31 17:43   ` Vladislav Shpilevoy via Tarantool-patches
2021-01-21 17:17 ` [Tarantool-patches] [PATCH 2/3] box/info: report replication.X.downstream.lag value Cyrill Gorcunov via Tarantool-patches
2021-01-27 11:56   ` Serge Petrenko via Tarantool-patches
2021-01-27 12:12     ` Cyrill Gorcunov via Tarantool-patches
2021-01-27 14:04       ` Serge Petrenko via Tarantool-patches
2021-01-27 14:38         ` Cyrill Gorcunov via Tarantool-patches
2021-01-27 14:44           ` Serge Petrenko via Tarantool-patches
2021-01-31 17:45   ` Vladislav Shpilevoy via Tarantool-patches
2021-01-21 17:17 ` [Tarantool-patches] [PATCH 3/3] test: replication/status -- fetch downstream lag field Cyrill Gorcunov via Tarantool-patches
2021-01-31 17:46   ` Vladislav Shpilevoy via Tarantool-patches
2021-01-21 17:17 ` Cyrill Gorcunov via Tarantool-patches
2021-01-21 17:23   ` Cyrill Gorcunov via Tarantool-patches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox