[tarantool-patches] [PATCH v2 5/5] Disallow lsn gaps while vclock following

Vladimir Davydov vdavydov.dev at gmail.com
Mon Jan 28 15:18:59 MSK 2019


On Tue, Jan 22, 2019 at 01:31:13PM +0300, Georgy Kirichenko wrote:
> Only one-step vclock following is allowed. This enforces wal and
> replication consistency against out of order execution.

Again, quite an obscure commit message. Please try to explain why you do
what you do so that even a sync replication noob like me can understand
it.

> 
> Prerequisite #980
> ---
>  src/box/replication.cc |  1 +
>  src/box/vclock.c       |  2 +-
>  src/box/xrow.c         |  2 +-
>  test/unit/vclock.cc    | 10 +++++-----
>  4 files changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/src/box/replication.cc b/src/box/replication.cc
> index 51e08886c..ee92a941b 100644
> --- a/src/box/replication.cc
> +++ b/src/box/replication.cc
> @@ -91,6 +91,7 @@ replication_init(void)
>  	replicaset.replica_by_id = (struct replica **)calloc(VCLOCK_MAX, sizeof(struct replica *));
>  	latch_create(&replicaset.applier.order_latch);
>  	vclock_create(&replicaset.applier.vclock);
> +	vclock_clear(&replicaset.applier.vclock);
>  }
>  
>  void
> diff --git a/src/box/vclock.c b/src/box/vclock.c
> index c297d1ff9..807da9109 100644
> --- a/src/box/vclock.c
> +++ b/src/box/vclock.c
> @@ -56,7 +56,7 @@ vclock_follow(struct vclock *vclock, uint32_t replica_id, int64_t lsn)
>  	assert(lsn >= 0);
>  	assert(replica_id < VCLOCK_MAX);
>  	int64_t prev_lsn = vclock->lsn[replica_id];
> -	assert(lsn > prev_lsn);
> +	assert(lsn == prev_lsn + 1);

AFAIU this may break recovery from a WAL created by an older Tarantool
version that allowed LSN gaps.

>  	/* Easier add each time than check. */
>  	vclock->map |= 1 << replica_id;
>  	vclock->lsn[replica_id] = lsn;



More information about the Tarantool-patches mailing list