[tarantool-patches] Re: [PATCH 1/3] Update only vshard part of a cfg on reload
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Mon Aug 6 20:03:22 MSK 2018
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
>
More information about the Tarantool-patches
mailing list