[Tarantool-patches] [PATCH v9 2/2] relay: provide information about downstream lag

Cyrill Gorcunov gorcunov at gmail.com
Mon Jun 21 11:44:30 MSK 2021


On Sun, Jun 20, 2021 at 04:37:21PM +0200, Vladislav Shpilevoy wrote:
> Hi! Thanks for the patch!
> 
> The test fails when I run it multiple times:
> 
> [014] Test failed! Result content mismatch:
> [014] --- replication/gh-5447-downstream-lag.result	Sun Jun 20 16:10:26 2021
> [014] +++ var/rejects/replication/gh-5447-downstream-lag.reject	Sun Jun 20 16:33:01 2021
> [014] @@ -37,7 +37,7 @@
> [014]  -- Upon replica startup there is no ACKs to process.
> [014]  assert(box.info.replication[replica_id].downstream.lag == 0)
> [014]   | ---
> [014] - | - true
> [014] + | - error: assertion failed!
> 
> See 4 comments below.

Hmm, didn't trigger on my machine. Gimme some time I'll try to hit this problem.

> 
> > @@ -629,6 +673,19 @@ 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.
> > +			 */
> > +			if (relay->txn_acked_tm < xrow.tm) {
> 
> 1. Why do you need this `if`? Why xrow.tm != 0 is not enough? (It is 0
> when replicate to old versions.) ACKs are sent in the same order as the
> rows, so there can't be any reordering.

The main purpose is to prevent the case where a peer sends us negative value,
for some reason. Nit sure though maybe we should not hide such case but
rather point out that there some weird node spamming us. I tend to agree
that comparision with zero might be more straightforward, will do.

> If it is intended to be used against time changes, this check won't work
> it seems. If time is moved far into the future, the check passes and the
> lag will be huge for some time. No protection. And there can't be.
> 
> If the time is moved far into the past, the check will freeze for the
> time shift size. Even when all the old transactions are acked and new
> ones are coming. Because you cached txn_acked_tm in the old time system.
> No protection either. Looks even like a bug, because the lag freezes
> regardless of whether there are new transactions ACKed with the new time
> system or not. It will wait for the new time system to catch up with the
> old txn_acked_tm.
> 
> If the timestamp is not needed, you can drop txn_acked_tm member from
> struct relay.

I'll drop this variable, and yes, there is no protection from clocks adjustments,
and it can't be fixed (for current code base).

> > +-- Insert a record and wakeup replica's WAL to process data.
> > +test_run:switch('default')
> > + | ---
> > + | - true
> > + | ...
> > +lsn = box.info.lsn
> > + | ---
> > + | ...
> > +box.space.test:insert({1})
> > + | ---
> > + | - [1]
> > + | ...
> > +test_run:wait_cond(function() return box.info.lsn > lsn end)
> 
> 2. You don't need it. You did blocking insert(), which returns only
> after the WAL write is done.

Yeah, it's redundant but harmless check, thanks.

> > +-- Cleanup everything.
> > +test_run:switch('default')
> > + | ---
> > + | - true
> > + | ...
> > +box.schema.user.revoke('guest', 'replication')
> 
> 3. You didn't drop the space.

Good catch, thanks!


More information about the Tarantool-patches mailing list