From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp17.mail.ru (smtp17.mail.ru [94.100.176.154]) (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 1AC3242EF5C for ; Mon, 22 Jun 2020 17:13:33 +0300 (MSK) References: <0bdc1b5e-82b4-2e24-ad06-26587b007742@tarantool.org> <20200522024206.GA24698@tarantool.org> From: Aleksandr Lyapunov Message-ID: <9820269f-95a1-4d11-c08f-c2dd2b642740@tarantool.org> Date: Mon, 22 Jun 2020 17:13:31 +0300 MIME-Version: 1.0 In-Reply-To: <20200522024206.GA24698@tarantool.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US 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: Nikita Pettik , Vladislav Shpilevoy Cc: tarantool-patches@dev.tarantool.org 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.