From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 5DC2B26960 for ; Fri, 6 Jul 2018 10:24:10 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GGzpNZEd8Kp7 for ; Fri, 6 Jul 2018 10:24:10 -0400 (EDT) Received: from smtp14.mail.ru (smtp14.mail.ru [94.100.181.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 08E9326673 for ; Fri, 6 Jul 2018 10:24:09 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH] Do not update schema_version on space:truncate(). References: <20180706114625.10152-1-sergepetrenko@tarantool.org> <20180706140754.GA3514@chai> From: Sergey Petrenko Message-ID: <7de60a16-1273-6c1b-12d5-8e05ef1e3ff2@tarantool.org> Date: Fri, 6 Jul 2018 17:24:06 +0300 MIME-Version: 1.0 In-Reply-To: <20180706140754.GA3514@chai> Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: 8bit Content-Language: ru Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: Konstantin Osipov , tarantool-patches@freelists.org 06.07.2018 17:07, Konstantin Osipov пишет: > * Serge Petrenko [18/07/06 14:52]: >> Schema version is used by both clients and internal modules to check >> whether there vere any updates in spaces and indices. While clients >> only need to be notified when there is a noticeable change, e.g. >> space is removed, internal components also need to be notified when >> something like space:truncate() happens, because even though this >> operation doesn't change space id or any of its indices, it creates a >> new space object, so all the pointers to the old object have to be updated. >> Currently both clients and internals share the same schema version, which >> leads to unnecessary updates on the client side. >> >> Fix this by implementing 2 separate counters for internal and public use: >> schema_state gets updated on every change, including recreation of the same >> space object, while schema_version is updated only when there are noticable >> changes for the clients. Introduce a new AlterOp to alter.cc to update >> public schema_version. >> Now all the internals reference schema_state, while all the clients use >> schema_version. box.iternal.schema_version() returns schema_version >> (the public one). > The new schema is instantiated/becomes effective in do(), not in commit. > > Before do() and commit() there is a yield and new queries > can see the new schema already. > Will fix. I thought it'd be a good idea to only increment when we already know we won't be returning to the old state. So I should increase schema_version in UpdateSchemaVersion::alter() and decrease it in UpdateSchemaVersion::rollback() ? And what about creation/drop of a space? Move schema_version increment to on_replace_dd_space() and decrement in case of failure to on_create_space_rollback() / on_drop_space_rollback() ?