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 1B36628178 for ; Mon, 6 Aug 2018 13:03:26 -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 2WTniKtBcXjg for ; Mon, 6 Aug 2018 13:03:26 -0400 (EDT) Received: from smtp61.i.mail.ru (smtp61.i.mail.ru [217.69.128.41]) (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 CBAA128176 for ; Mon, 6 Aug 2018 13:03:25 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH 1/3] Update only vshard part of a cfg on reload References: <37ba10547bf64fd880734b0550e4865f58dda14a.1533054045.git.avkhatskevich@tarantool.org> <55486f60-a630-1d19-69e0-5cf99c01f319@tarantool.org> From: Vladislav Shpilevoy Message-ID: <1457a321-3ed1-ed05-74c2-e4f8508a0156@tarantool.org> Date: Mon, 6 Aug 2018 20:03:22 +0300 MIME-Version: 1.0 In-Reply-To: <55486f60-a630-1d19-69e0-5cf99c01f319@tarantool.org> Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Language: en-US Content-Transfer-Encoding: 8bit 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: Alex Khatskevich , tarantool-patches@freelists.org Thanks for the patch! See 3 comments below. > diff --git a/vshard/storage/init.lua b/vshard/storage/init.lua > index 102b942..40216ea 100644 > --- a/vshard/storage/init.lua > +++ b/vshard/storage/init.lua > @@ -1553,18 +1553,19 @@ local function storage_cfg(cfg, this_replica_uuid) >      -- >      -- If a master role of the replica is not changed, then >      -- 'read_only' can be set right here. > -    cfg.listen = cfg.listen or this_replica.uri > -    if cfg.replication == nil and this_replicaset.master and not is_master then > -        cfg.replication = {this_replicaset.master.uri} > +    box_cfg.listen = box_cfg.listen or this_replica.uri > +    if box_cfg.replication == nil and this_replicaset.master > +       and not is_master then > +        box_cfg.replication = {this_replicaset.master.uri} >      else > -        cfg.replication = {} > +        box_cfg.replication = {} >      end >      if was_master == is_master then > -        cfg.read_only = not is_master > +        box_cfg.read_only = not is_master >      end >      if type(box.cfg) == 'function' then > -        cfg.instance_uuid = this_replica.uuid > -        cfg.replicaset_uuid = this_replicaset.uuid > +        box_cfg.instance_uuid = this_replica.uuid > +        box_cfg.replicaset_uuid = this_replicaset.uuid 1. All these box_cfg manipulations should be done under 'if not is_reload' I think. >      else >          local info = box.info >          if this_replica_uuid ~= info.uuid then > @@ -1607,27 +1610,27 @@ local function storage_cfg(cfg, this_replica_uuid) >          local_on_master_enable_prepare() >      end > > -    local box_cfg = table.copy(cfg) > -    lcfg.remove_non_box_options(box_cfg) > -    local ok, err = pcall(box.cfg, box_cfg) > -    while M.errinj.ERRINJ_CFG_DELAY do > -        lfiber.sleep(0.01) > -    end > -    if not ok then > -        M.sync_timeout = old_sync_timeout > -        if was_master and not is_master then > -            local_on_master_disable_abort() > +    if not is_reload then > +        local ok, err = true, nil > +        ok, err = pcall(box.cfg, box_cfg) 2. Why do you need to announce 'local ok, err' before their usage on the next line? > +        while M.errinj.ERRINJ_CFG_DELAY do > +            lfiber.sleep(0.01) >          end > -        if not was_master and is_master then > -            local_on_master_enable_abort() > +        if not ok then > +            M.sync_timeout = old_sync_timeout > +            if was_master and not is_master then > +                local_on_master_disable_abort() > +            end > +            if not was_master and is_master then > +                local_on_master_enable_abort() > +            end > +            error(err) >          end > -        error(err) > +        log.info("Box has been configured") > +        local uri = luri.parse(this_replica.uri) > +        box.once("vshard:storage:1", storage_schema_v1, uri.login, uri.password) >      end > > -    log.info("Box has been configured") > -    local uri = luri.parse(this_replica.uri) > -    box.once("vshard:storage:1", storage_schema_v1, uri.login, uri.password) > - >      lreplicaset.rebind_replicasets(new_replicasets, M.replicasets) >      lreplicaset.outdate_replicasets(M.replicasets) >      M.replicasets = new_replicasets > @@ -1874,7 +1877,7 @@ if not rawget(_G, MODULE_INTERNALS) then >      rawset(_G, MODULE_INTERNALS, M) >  else >      reload_evolution.upgrade(M) > -    storage_cfg(M.current_cfg, M.this_replica.uuid) > +    storage_cfg(M.current_cfg, M.this_replica.uuid, true) 3. I see that you have stored vshard_cfg in M.current_cfg. Not a full config. So it does not have any box options. And it causes a question - why do you need to separate reload from non-reload, if reload anyway in such implementation is like 'box.cfg{}' call with no parameters? And if you do not store box_cfg options how are you going to compare configs when we will implement atomic cfg over cluster? >      M.module_version = M.module_version + 1 >  end >