Tarantool development patches archive
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@gmail.com>
To: Serge Petrenko <sergepetrenko@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org, v.shpilevoy@tarantool.org
Subject: Re: [Tarantool-patches] [PATCH v2 2/2] wal: reorder tx rows so that a tx ends on a global row
Date: Mon, 25 May 2020 18:13:27 +0300	[thread overview]
Message-ID: <20200525151327.GB2464@grain> (raw)
In-Reply-To: <d414d4c52942658c9b36581e9f1e12956a9270e8.1590403792.git.sergepetrenko@tarantool.org>

On Mon, May 25, 2020 at 01:58:56PM +0300, Serge Petrenko wrote:
...
> diff --git a/src/box/wal.c b/src/box/wal.c
> index ef4d84920..0921c7261 100644
> --- a/src/box/wal.c
> +++ b/src/box/wal.c
> @@ -958,6 +958,7 @@ wal_assign_lsn(struct vclock *vclock_diff, struct vclock *base,
>  	int64_t tsn = 0;
>  	struct xrow_header **start = row;
>  	struct xrow_header **first_glob_row = row;
> +	struct xrow_header **last_glob_row = end - 1;
>  	/** Assign LSN to all local rows. */
>  	for ( ; row < end; row++) {
>  		if ((*row)->replica_id == 0) {
> @@ -971,6 +972,7 @@ wal_assign_lsn(struct vclock *vclock_diff, struct vclock *base,
>  			 */
>  			if ((*row)->group_id != GROUP_LOCAL) {
>  				(*row)->replica_id = instance_id;
> +				last_glob_row = row;
>  			}
>  
>  			(*row)->lsn = vclock_inc(vclock_diff, (*row)->replica_id) +
> @@ -987,7 +989,7 @@ wal_assign_lsn(struct vclock *vclock_diff, struct vclock *base,
>  				first_glob_row = row;
>  			}
>  			(*row)->tsn = tsn == 0 ? (*start)->lsn : tsn;
> -			(*row)->is_commit = row == end - 1;
> +			(*row)->is_commit = false;
>  		} else {
>  			int64_t diff = (*row)->lsn - vclock_get(base, (*row)->replica_id);
>  			if (diff <= vclock_get(vclock_diff,
> @@ -1013,6 +1015,21 @@ wal_assign_lsn(struct vclock *vclock_diff, struct vclock *base,
>  	 */
>  	for (row = start; row < first_glob_row; row++)
>  		(*row)->tsn = tsn;
> +
> +	/*
> +	 * If a mixed transaction ends on a local row, float up
> +	 * the last global row, so that the upper tx boundary is
> +	 * delivered to the replica.
> +	 */
> +	if (last_glob_row < end - 1) {
> +		struct xrow_header *tmp = *last_glob_row;
> +		memmove(last_glob_row, last_glob_row + 1,
> +			(end - 1 - last_glob_row) *
> +			sizeof(struct xrow_header *));
> +		*(end - 1) = tmp;
> +	}

Sergey, I see no errors here still this memove call somehow
worries me, can't explain why, some gut feeling. Maybe because
we're mangling arguments.

That said while it fixes the issue (and we really need this
fix asap)

Reviewed-by: Cyrill Gorcunov <gorcunov@gmail.com>

but maybe we should come back to this code a bit later
and rethink it.

> +
> +	(*(end - 1))->is_commit = true;
>  }

  reply	other threads:[~2020-05-25 15:13 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-25 10:58 [Tarantool-patches] [PATCH v2 0/2] fix replication tx boundaries after local space rework Serge Petrenko
2020-05-25 10:58 ` [Tarantool-patches] [PATCH v2 1/2] wal: fix tx boundaries Serge Petrenko
2020-05-28 22:53   ` Vladislav Shpilevoy
2020-05-29 11:09     ` Serge Petrenko
2020-05-25 10:58 ` [Tarantool-patches] [PATCH v2 2/2] wal: reorder tx rows so that a tx ends on a global row Serge Petrenko
2020-05-25 15:13   ` Cyrill Gorcunov [this message]
2020-05-25 16:34   ` Konstantin Osipov
2020-05-25 18:35     ` Cyrill Gorcunov
2020-05-25 20:42       ` Konstantin Osipov
2020-05-26  9:41     ` Serge Petrenko
2020-05-26 11:41       ` Konstantin Osipov
2020-05-26 12:08         ` Serge Petrenko
2020-05-28 22:54   ` Vladislav Shpilevoy
2020-05-29  8:13     ` Konstantin Osipov
2020-05-29 11:42     ` Serge Petrenko
2020-05-29 11:51       ` Konstantin Osipov
2020-05-29 12:07         ` Cyrill Gorcunov
2020-05-29 12:07           ` Cyrill Gorcunov
2020-05-29 12:15         ` Serge Petrenko
2020-05-29 13:44           ` Konstantin Osipov
2020-05-29 15:55             ` Serge Petrenko
2020-06-01 13:40       ` Vladislav Shpilevoy
2020-06-01 16:02         ` Sergey Ostanevich
2020-06-01 17:06           ` Vladislav Shpilevoy
2020-05-28 22:53 ` [Tarantool-patches] [PATCH v2 0/2] fix replication tx boundaries after local space rework Vladislav Shpilevoy
2020-05-29 11:03   ` Serge Petrenko

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=20200525151327.GB2464@grain \
    --to=gorcunov@gmail.com \
    --cc=sergepetrenko@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v2 2/2] wal: reorder tx rows so that a tx ends on a global row' \
    /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