From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Thu, 14 Feb 2019 17:04:54 +0300 From: Vladimir Davydov Subject: Re: [tarantool-patches] [PATCH v2 2/2] Track wal vclock changes instead of copying Message-ID: <20190214140453.axpxyjygdldbubcn@esperanza> References: <9b0d551519dd24f3c456fc28e512e26e953275fc.1550046797.git.georgy@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9b0d551519dd24f3c456fc28e512e26e953275fc.1550046797.git.georgy@tarantool.org> To: Georgy Kirichenko Cc: tarantool-patches@freelists.org List-ID: On Wed, Feb 13, 2019 at 11:35:17AM +0300, Georgy Kirichenko wrote: > +/* > + * Assign lsn and replica identifier for local writes and track > + * row into vclock_diff. > + */ > static void > -wal_assign_lsn(struct vclock *vclock, struct xrow_header **row, > +wal_assign_lsn(struct vclock *vclock_diff, struct vclock *base, > + struct xrow_header **row, > struct xrow_header **end) > { > /** Assign LSN to all local rows. */ > for ( ; row < end; row++) { > if ((*row)->replica_id == 0) { > - (*row)->lsn = vclock_inc(vclock, instance_id); > + (*row)->lsn = vclock_inc(vclock_diff, instance_id) + > + vclock_get(base, instance_id); > (*row)->replica_id = instance_id; > } else { > - vclock_follow_xrow(vclock, *row); > + vclock_follow(vclock_diff, (*row)->replica_id, > + (*row)->lsn - vclock_get(base, > + (*row)->replica_id)); vclock_follow_xrow() checks that LSN doesn't go backwards and panics if it does. vclock_follow() doesn't have such check.