From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id C1E824696C6 for ; Sat, 4 Apr 2020 23:51:54 +0300 (MSK) References: <3162d52a68b95a43a0756dd2e03e4418dd80eafa.1585565637.git.sergepetrenko@tarantool.org> From: Vladislav Shpilevoy Message-ID: <0f687ed6-2a15-6b1b-1c6e-f98814f9e162@tarantool.org> Date: Sat, 4 Apr 2020 22:51:53 +0200 MIME-Version: 1.0 In-Reply-To: <3162d52a68b95a43a0756dd2e03e4418dd80eafa.1585565637.git.sergepetrenko@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Tarantool-patches] [PATCH v5 1/4] vclock: add an ability to reset individual clock components List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Serge Petrenko , kostja.osipov@gmail.com Cc: tarantool-patches@dev.tarantool.org Thanks for the patch! On 30/03/2020 13:04, Serge Petrenko wrote: > Anonymous replicas use 0th vclock component to sign local rows. > vclock_reset will allow to zero-out 0th vclock component when an > anonymous replica is promoted to a normal one and sends out its vclock > to other joining instances, as to not pollute their own 0th vclock > component. > Also add a shortcut for vclcok_copy() + vclock_reset() for 0th clock > component: vclock_copy_ignore0() > > Follow-up #3186 > Prerequisite #4114 > --- > src/box/vclock.c | 15 +++++++++++++++ > src/box/vclock.h | 24 ++++++++++++++++++++++++ > 2 files changed, 39 insertions(+) > > diff --git a/src/box/vclock.c b/src/box/vclock.c > index 90ae27591..ac3e9fccd 100644 > --- a/src/box/vclock.c > +++ b/src/box/vclock.c > @@ -37,6 +37,21 @@ > #include "diag.h" > #include "tt_static.h" > > +void > +vclock_reset(struct vclock *vclock, uint32_t replica_id, int64_t lsn) This is probably already discussed, but why do we have general reset for arbitrary replica_id+lsn, and yet we have specialized copy_ignore0? Why this function was not called vclock_reset0() with replica_id == 0 and lsn == 0 always? > +{ > + assert(lsn >= 0); > + assert(replica_id < VCLOCK_MAX); > + vclock->signature -= vclock_get(vclock, replica_id); > + if (lsn == 0) { > + vclock->map &= ~(1 << replica_id); > + return; > + } > + vclock->lsn[replica_id] = lsn; > + vclock->map |= 1 << replica_id; > + vclock->signature += lsn; > +}