[Tarantool-patches] [PATCH v2 2/2] wal: reorder tx rows so that a tx ends on a global row
Cyrill Gorcunov
gorcunov at gmail.com
Mon May 25 18:13:27 MSK 2020
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 at gmail.com>
but maybe we should come back to this code a bit later
and rethink it.
> +
> + (*(end - 1))->is_commit = true;
> }
More information about the Tarantool-patches
mailing list