From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Mon, 28 Jan 2019 15:18:59 +0300 From: Vladimir Davydov Subject: Re: [tarantool-patches] [PATCH v2 5/5] Disallow lsn gaps while vclock following Message-ID: <20190128121859.h6yvexnifr6iqf5k@esperanza> References: <5a4684b673896b50bcb644842510de40fe91d1cf.1548152776.git.georgy@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5a4684b673896b50bcb644842510de40fe91d1cf.1548152776.git.georgy@tarantool.org> To: Georgy Kirichenko Cc: tarantool-patches@freelists.org List-ID: 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;