From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp33.i.mail.ru (smtp33.i.mail.ru [94.100.177.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id E16FF41C5DA for ; Mon, 22 Jun 2020 23:21:09 +0300 (MSK) Date: Mon, 22 Jun 2020 20:21:08 +0000 From: Nikita Pettik Message-ID: <20200622202108.GA32744@tarantool.org> References: <0bdc1b5e-82b4-2e24-ad06-26587b007742@tarantool.org> <20200522024206.GA24698@tarantool.org> <9820269f-95a1-4d11-c08f-c2dd2b642740@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <9820269f-95a1-4d11-c08f-c2dd2b642740@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH 0/2] Validate result of upserts squash & skip invalid upserts which can't be applied List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Aleksandr Lyapunov Cc: tarantool-patches@dev.tarantool.org, Vladislav Shpilevoy 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...