From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp34.i.mail.ru (smtp34.i.mail.ru [94.100.177.94]) (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 0659F469710 for ; Thu, 7 May 2020 15:28:05 +0300 (MSK) Date: Thu, 7 May 2020 12:28:05 +0000 From: Nikita Pettik Message-ID: <20200507122804.GA11724@tarantool.org> References: <1a626bac0c6d0d79934f1e144bb92709f4bd4963.1587948306.git.korablev@tarantool.org> <20200507002922.GA9992@tarantool.org> <932b750d-abd7-1de9-1654-2781ac49a6ba@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <932b750d-abd7-1de9-1654-2781ac49a6ba@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH v3 2/3] vinyl: clean-up unprocessed read views in *_build_read_views() List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Aleksandr Lyapunov Cc: tarantool-patches@dev.tarantool.org, v.shpilevoy@tarantool.org On 07 May 11:44, Aleksandr Lyapunov wrote: > Thanks for the patch! Almost perfect, except some looking like a misprint, > see my comments below. > > On 5/7/20 3:29 AM, Nikita Pettik wrote: > > > > On the other hand clean-up provided by vy_read_view_stmt_destroy() > > is safe: it nullifies rv->tuple and rv->history so that next call > > of vy_read_view_stmt_destroy() will be no-op in fact. > > Anyway, I've refactored this code according to your plan, so > > vy_read_view_stmt_destroy() now unrefs only resulting tuple. > Yes, as I said your code was correct, but I'm talking about good structure > of the code that is easier to support and (I hope) leave less chances > to make a mistake or forget something like cleanup. Divide responsibility > between parts of code and conquer! Agree. > > > 2. The history must be destructed after call to > > > vy_write_iterator_build_history in any case, > > > whether an error occurred or not (comment about it?). > > But histories are used in vy_read_view_merge(). Do you mean destruct all > > histories after they are processed (i.e. before region_truncate())? > Exactly, in the end of vy_write_iterator_build_read_views. > > > > - if (rc != 0) { > > - for (int i = 0; i < stream->rv_count; ++i) > > - vy_read_view_stmt_destroy(&stream->read_views[i]); > > - } else if (stream->is_last_level && > > - stream->deferred_delete_stmt != NULL) { > > + if (stream->is_last_level && stream->deferred_delete_stmt != NULL) { > > vy_stmt_unref_if_possible(stream->deferred_delete_stmt); > > stream->deferred_delete_stmt = NULL; > > } > Originally it was: > > if (rc == 0 && stream->is_last_level && stream->deferred_delete_stmt != NULL) > > Are you sure you want to change it, or it was a misprint?. Oh, it's misprint for sure. Fixed.