From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp16.mail.ru (smtp16.mail.ru [94.100.176.153]) (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 1648E469710 for ; Thu, 7 May 2020 11:44:38 +0300 (MSK) References: <1a626bac0c6d0d79934f1e144bb92709f4bd4963.1587948306.git.korablev@tarantool.org> <20200507002922.GA9992@tarantool.org> From: Aleksandr Lyapunov Message-ID: <932b750d-abd7-1de9-1654-2781ac49a6ba@tarantool.org> Date: Thu, 7 May 2020 11:44:36 +0300 MIME-Version: 1.0 In-Reply-To: <20200507002922.GA9992@tarantool.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US 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: Nikita Pettik Cc: tarantool-patches@dev.tarantool.org, v.shpilevoy@tarantool.org 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! > >> 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?.