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 A0E29218DE for ; Tue, 31 Jul 2018 07:05:15 -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 ekqLvGZGZsih for ; Tue, 31 Jul 2018 07:05:15 -0400 (EDT) Received: from smtp33.i.mail.ru (smtp33.i.mail.ru [94.100.177.93]) (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 4DA2B21852 for ; Tue, 31 Jul 2018 07:05:15 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH 1/4] Fix races related to object outdating References: <18f2ede05fa4a77bf0bd2abb64c25df0e3c574d6.1532940401.git.avkhatskevich@tarantool.org> <4a8e9e20-561d-6896-ea8c-8517add2bc50@tarantool.org> From: Alex Khatskevich Message-ID: <1eeb6917-0153-919d-de56-c21052ea42f9@tarantool.org> Date: Tue, 31 Jul 2018 14:05:12 +0300 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: 8bit Content-Language: en-US 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: Vladislav Shpilevoy , tarantool-patches@freelists.org >>>> diff --git a/vshard/router/init.lua b/vshard/router/init.lua >>>> index 142ddb6..1a0ed2f 100644 >>>> --- a/vshard/router/init.lua >>>> +++ b/vshard/router/init.lua >>>> @@ -88,15 +94,18 @@ local function bucket_discovery(bucket_id) >>>>       log.verbose("Discovering bucket %d", bucket_id) >>>>       local last_err = nil >>>>       local unreachable_uuid = nil >>>> -    for uuid, replicaset in pairs(M.replicasets) do >>>> -        local _, err = >>>> -            replicaset:callrw('vshard.storage.bucket_stat', >>>> {bucket_id}) >>>> -        if err == nil then >>>> -            bucket_set(bucket_id, replicaset) >>>> -            return replicaset >>>> -        elseif err.code ~= lerror.code.WRONG_BUCKET then >>>> -            last_err = err >>>> -            unreachable_uuid = uuid >>>> +    for uuid, _ in pairs(M.replicasets) do >>>> +        -- Handle reload/reconfigure. >>>> +        replicaset = M.replicasets[uuid] >>>> +        if replicaset then >>>> +            local _, err = >>>> + replicaset:callrw('vshard.storage.bucket_stat', {bucket_id}) >>>> +            if err == nil then >>>> +                return bucket_set(bucket_id, replicaset.uuid) >>> >>> Do not return error immediately. You can continue iteration in the hope >>> of finding the bucket out on one of next replicasets. So here you >>> do 'if bucket_set ~= nil then return result end'. Else continue. >> Please, read it again. It seems like you misunderstood something. >> I did not change the behavior here. > > You changed the behavior here. Before bucket_set never failed when > 'err ~= nil' always a non-nil result was returned, even though outdated. > Now you return nil. Discussed verbally. Further iteration in case of the error do not speeds up anything.