[tarantool-patches] Re: [PATCH][vshard] Log warning on duplicate replica.name
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Thu Jun 7 17:49:09 MSK 2018
Thanks the patch! Almost perfect. But one minor comment. See it below.
On 07/06/2018 14:50, AKhatskevich wrote:
> In case duplicate replica.name found, log warning.
>
> Closes #101
> ---
> Branch: https://github.com/tarantool/vshard/tree/kh/gh-101-duplicate_name_warning
> Issue: https://github.com/tarantool/vshard/issues/101
> test/unit/config.result | 62 +++++++++++++++++++++++++++++++++++++++++++++--
> test/unit/config.test.lua | 29 ++++++++++++++++++++--
> vshard/cfg.lua | 8 ++++++
> 3 files changed, 95 insertions(+), 4 deletions(-)
>
> diff --git a/vshard/cfg.lua b/vshard/cfg.lua
> index a389eea..c3cf5d7 100644
> --- a/vshard/cfg.lua
> +++ b/vshard/cfg.lua
> @@ -141,6 +141,7 @@ end
> local function check_sharding(sharding)
> local uuids = {}
> local uris = {}
> + local names = {}
> for replicaset_uuid, replicaset in pairs(sharding) do
> if uuids[replicaset_uuid] then
> error(string.format('Duplicate uuid %s', replicaset_uuid))
> @@ -159,6 +160,13 @@ local function check_sharding(sharding)
> error(string.format('Duplicate uuid %s', replica_uuid))
> end
> uuids[replica_uuid] = true
> + -- log warning in case replica.name duplicate found
> + if replica.name then
> + if names[replica.name] then
> + log.warn('Duplicate replica.name found: %s', replica.name)
> + end
> + names[replica.name] = true
Please, print the warning on each duplicate only once. Now if I use the same name
N >= 2 times, the warning for the name is printed N - 1 times.
Example:
name1, name1, name1, name1
In the log I see:
Duplicate replica.name found: name1
Duplicate replica.name found: name1
Duplicate replica.name found: name1
Must be:
Duplicate replica.name found: name1
For example, you can store in 'names' not booleans, but count of name
duplicates. And print the warning only when the count is 2.
> + end
> end
> end
> end
>
More information about the Tarantool-patches
mailing list