[Tarantool-patches] [PATCH 0/2] Validate result of upserts squash & skip invalid upserts which can't be applied
Nikita Pettik
korablev at tarantool.org
Mon Jun 22 23:21:08 MSK 2020
On 22 Jun 17:13, Aleksandr Lyapunov wrote:
> HI, thanks for the patch! see one comment below
>
> On 5/22/20 5:42 AM, Nikita Pettik wrote:
> >
> > diff --git a/src/box/vinyl.c b/src/box/vinyl.c
> > index 55a4c8fb7..b39e3b9d8 100644
> > --- a/src/box/vinyl.c
> > +++ b/src/box/vinyl.c
> > @@ -3539,10 +3539,21 @@ vy_squash_process(struct vy_squash *squash)
> > if (vy_tuple_compare(result, mem_stmt, lsm->cmp_def) != 0 ||
> > vy_stmt_type(mem_stmt) != IPROTO_UPSERT)
> > break;
> > - assert(vy_stmt_lsn(mem_stmt) >= MAX_LSN);
> > - vy_stmt_set_n_upserts((struct tuple *)mem_stmt, n_upserts);
> > - if (n_upserts <= VY_UPSERT_THRESHOLD)
> > - ++n_upserts;
> > + /*
> > + * Upsert was not applied in vy_history_apply(),
> > + * but it still resides in tree memory. Ignore
> > + * such statements and do not account them while
> > + * counting upserts. Otherwise invalid upserts will
> > + * get stack and won't allow other upserts to squash.
> > + */
> > + if (vy_stmt_lsn(mem_stmt) >= MAX_LSN) {
> > + vy_stmt_set_n_upserts((struct tuple *) mem_stmt,
> > + n_upserts);
> > + if (n_upserts <= VY_UPSERT_THRESHOLD)
> > + ++n_upserts;
> > + } else {
> > + vy_stmt_set_n_upserts((struct tuple *) mem_stmt, 0);
> > + }
> I bet we should just remove assert here. If mem_stmt have
> a valid LSN now - it is a valid statement. The first of them must
> have n_upserts=0, the second - 1 etc, and n_upsert of following
> prepared statements must continue the sequence.
What is the point of keeping counting n_upserts for upserts
which can't be squashed? For sure we can simply remove assertion,
but then after accumulating more than 128 upserts which can't
be applied, vy_squash_process won't be called till dump...
More information about the Tarantool-patches
mailing list