From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp3.mail.ru (smtp3.mail.ru [94.100.179.58]) (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 EBEF042EF5C for ; Mon, 22 Jun 2020 22:28:04 +0300 (MSK) References: From: Aleksandr Lyapunov Message-ID: <2baa1b19-c357-754a-d13c-9ced27490e88@tarantool.org> Date: Mon, 22 Jun 2020 22:28:03 +0300 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Subject: Re: [Tarantool-patches] [PATCH 1/2] vinyl: validate resulting tuple after upsert is applied List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Nikita Pettik , tarantool-patches@dev.tarantool.org Cc: v.shpilevoy@tarantool.org Hi! thank again. See my comment below. On 4/14/20 12:55 AM, Nikita Pettik wrote: > diff --git a/src/box/vy_upsert.c b/src/box/vy_upsert.c > index ebea2789c..6855b9820 100644 > --- a/src/box/vy_upsert.c > +++ b/src/box/vy_upsert.c > @@ -134,6 +134,10 @@ vy_apply_upsert(const struct tuple *new_stmt, const struct tuple *old_stmt, > &mp_size, 0, suppress_error, > &column_mask); > result_mp_end = result_mp + mp_size; > + if (tuple_validate_raw(format, result_mp) != 0) { > + region_truncate(region, region_svp); > + return NULL; > + } That is wrong for UPSERT-UPSERT case. The result of applying an upsert to another must be such a cumulative upsert that being applied to anything must have the same result as two original upserts applied sequentially. Also in any case, inapplicable ops must be skipped and inapplicable whole upsert must be skipped. Suppose we have two upserts: upsert1 = {tuple1, {ops1}} and upsert2 = {tuple2, {ops2}}, and {ops2} are not applicable to tuple1. What cumulative upsert must we create? 1)if apllied to NULL or DELETE first upsert must insert tuple1 and upsert2 must be skipped and thus the result must be tuple1. 2)if applied to some good tuple - all ops {ops1,ops2} must be applied. Thus the cumulative upsert must be like: {tuple1, {ops1, ops2}} But in your code you create: {tuple1, {ops1}}