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 71826259D9 for ; Thu, 7 Jun 2018 10:49:12 -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 qcBLPRXkEDSC for ; Thu, 7 Jun 2018 10:49:12 -0400 (EDT) Received: from smtp56.i.mail.ru (smtp56.i.mail.ru [217.69.128.36]) (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 309C52598D for ; Thu, 7 Jun 2018 10:49:12 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH][vshard] Log warning on duplicate replica.name References: <20180607115043.3851-1-avkhatskevich@tarantool.org> From: Vladislav Shpilevoy Message-ID: Date: Thu, 7 Jun 2018 17:49:09 +0300 MIME-Version: 1.0 In-Reply-To: <20180607115043.3851-1-avkhatskevich@tarantool.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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: tarantool-patches@freelists.org, AKhatskevich 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 >