Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: "Георгий Кириченко" <georgy@tarantool.org>
Cc: tarantool-patches@freelists.org
Subject: Re: [tarantool-patches] [PATCH v2 1/5] Do not promote wal vclock for failed writes
Date: Tue, 29 Jan 2019 14:58:43 +0300	[thread overview]
Message-ID: <20190129115843.763xi7h3eou7ekbl@esperanza> (raw)
In-Reply-To: <2238035.WnxgNYYFuH@home.lan>

On Tue, Jan 29, 2019 at 01:22:21PM +0300, Георгий Кириченко wrote:
> On Monday, January 28, 2019 2:20:18 PM MSK Vladimir Davydov wrote:
> > On Tue, Jan 22, 2019 at 01:31:09PM +0300, Georgy Kirichenko wrote:
> > > Increase replica lsn only if row was successfully written to disk. This
> > > prevents wal from lsn gaps in case of IO errors and enforces wal
> > > consistency.
> > > 
> > > Needs for #980
> > > ---
> > > 
> > >  src/box/wal.c                     | 19 ++++++---
> > >  test/xlog/errinj.result           |  1 -
> > >  test/xlog/panic_on_lsn_gap.result | 65 +++++++++++++++----------------
> > >  3 files changed, 45 insertions(+), 40 deletions(-)
> > > 
> > > diff --git a/src/box/wal.c b/src/box/wal.c
> > > index 3b50d3629..a55b544aa 100644
> > > --- a/src/box/wal.c
> > > +++ b/src/box/wal.c
> > > @@ -901,16 +901,16 @@ wal_writer_begin_rollback(struct wal_writer *writer)
> > > 
> > >  }
> > >  
> > >  static void
> > > 
> > > -wal_assign_lsn(struct wal_writer *writer, struct xrow_header **row,
> > > +wal_assign_lsn(struct vclock *vclock, 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(&writer->vclock, instance_id);
> > > +			(*row)->lsn = vclock_inc(vclock, instance_id);
> > > 
> > >  			(*row)->replica_id = instance_id;
> > >  		
> > >  		} else {
> > > 
> > > -			vclock_follow_xrow(&writer->vclock, *row);
> > > +			vclock_follow_xrow(vclock, *row);
> > > 
> > >  		}
> > >  	
> > >  	}
> > >  
> > >  }
> > > 
> > > @@ -922,6 +922,11 @@ wal_write_to_disk(struct cmsg *msg)
> > > 
> > >  	struct wal_msg *wal_msg = (struct wal_msg *) msg;
> > >  	struct error *error;
> > > 
> > > +	/* Local vclock copy. */
> > > +	struct vclock vclock;
> > > +	vclock_create(&vclock);
> > > +	vclock_copy(&vclock, &writer->vclock);
> > > +
> > > 
> > >  	struct errinj *inj = errinj(ERRINJ_WAL_DELAY, ERRINJ_BOOL);
> > >  	while (inj != NULL && inj->bparam)
> > >  	
> > >  		usleep(10);
> > > 
> > > @@ -974,14 +979,15 @@ wal_write_to_disk(struct cmsg *msg)
> > > 
> > >  	struct journal_entry *entry;
> > >  	struct stailq_entry *last_committed = NULL;
> > >  	stailq_foreach_entry(entry, &wal_msg->commit, fifo) {
> > > 
> > > -		wal_assign_lsn(writer, entry->rows, entry->rows + entry-
> >n_rows);
> > > -		entry->res = vclock_sum(&writer->vclock);
> > > +		wal_assign_lsn(&vclock, entry->rows, entry->rows + entry-
> >n_rows);
> > > +		entry->res = vclock_sum(&vclock);
> > > 
> > >  		rc = xlog_write_entry(l, entry);
> > >  		if (rc < 0)
> > >  		
> > >  			goto done;
> > >  		
> > >  		if (rc > 0) {
> > >  		
> > >  			writer->checkpoint_wal_size += rc;
> > >  			last_committed = &entry->fifo;
> > > 
> > > +			vclock_copy(&writer->vclock, &vclock);
> > 
> > I don't like that you copy a vclock after applying each entry.
> > Currently, it should be pretty cheap, but in future, when we make
> > vclock store any number of ids, this might get pretty heavy.
> > Can we minimize the number of memcpys somehow, ideally do it only
> > on the rollback path?
> In that case we should preserve vclock for rollback but it can be done only 
> with vclock_copy to.  vclock_copy is used only for whole batch with all 
> entries.
> When we introduce unlimited vclock we should introduce vclock_diff also and 
> then use them.

Fair enough.

  reply	other threads:[~2019-01-29 11:58 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-22 10:31 [tarantool-patches] [PATCH v2 0/5] Strong sequentially LSN in journal Georgy Kirichenko
2019-01-22 10:31 ` [tarantool-patches] [PATCH v2 1/5] Do not promote wal vclock for failed writes Georgy Kirichenko
2019-01-28 11:20   ` Vladimir Davydov
2019-01-29 10:22     ` Георгий Кириченко
2019-01-29 11:58       ` Vladimir Davydov [this message]
2019-01-22 10:31 ` [tarantool-patches] [PATCH v2 2/5] Update replicaset vclock from wal Georgy Kirichenko
2019-01-28 11:59   ` Vladimir Davydov
2019-01-29 10:33     ` [tarantool-patches] " Георгий Кириченко
2019-01-22 10:31 ` [tarantool-patches] [PATCH v2 3/5] Enforce applier out of order protection Georgy Kirichenko
2019-01-28 12:09   ` Vladimir Davydov
2019-01-29 10:30     ` [tarantool-patches] " Георгий Кириченко
2019-01-29 12:00       ` Vladimir Davydov
2019-01-22 10:31 ` [tarantool-patches] [PATCH v2 4/5] Emit NOP if an applier skips row Georgy Kirichenko
2019-01-28 12:15   ` Vladimir Davydov
2019-02-08 16:50   ` [tarantool-patches] " Konstantin Osipov
2019-01-22 10:31 ` [tarantool-patches] [PATCH v2 5/5] Disallow lsn gaps while vclock following Georgy Kirichenko
2019-01-28 12:18   ` Vladimir Davydov
2019-01-28 11:15 ` [tarantool-patches] [PATCH v2 0/5] Strong sequentially LSN in journal Vladimir Davydov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190129115843.763xi7h3eou7ekbl@esperanza \
    --to=vdavydov.dev@gmail.com \
    --cc=georgy@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH v2 1/5] Do not promote wal vclock for failed writes' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox