From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> To: tarantool-patches@freelists.org, AKhatskevich <avkhatskevich@tarantool.org> Subject: [tarantool-patches] Re: [PATCH 1/4] Fix races related to object outdating Date: Mon, 30 Jul 2018 14:55:31 +0300 [thread overview] Message-ID: <4a8e9e20-561d-6896-ea8c-8517add2bc50@tarantool.org> (raw) In-Reply-To: <18f2ede05fa4a77bf0bd2abb64c25df0e3c574d6.1532940401.git.avkhatskevich@tarantool.org> Hi! Thanks for the patch! See 1 comment below and fixes on the branch in a separate commit. Please, look and squash. On 30/07/2018 11:56, AKhatskevich wrote: > Reload/reconfigure may replace many of M fields during any yield. > Old objects should not be accessed after they are outdated. > > This commit handles such cases within `vshard.router`. > --- > vshard/replicaset.lua | 30 ++++++++++++++----------- > vshard/router/init.lua | 58 +++++++++++++++++++++++++++++-------------------- > vshard/storage/init.lua | 1 + > 3 files changed, 52 insertions(+), 37 deletions(-) > > 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. > + elseif err.code ~= lerror.code.WRONG_BUCKET then > + last_err = err > + unreachable_uuid = uuid > + end > end > end > local err = nil
next prev parent reply other threads:[~2018-07-30 11:55 UTC|newest] Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-07-30 8:56 [tarantool-patches] [PATCH v4] vshard module reload AKhatskevich 2018-07-30 8:56 ` [tarantool-patches] [PATCH 1/4] Fix races related to object outdating AKhatskevich 2018-07-30 11:55 ` Vladislav Shpilevoy [this message] 2018-07-30 16:46 ` [tarantool-patches] " Alex Khatskevich 2018-07-30 17:50 ` Vladislav Shpilevoy 2018-07-31 11:05 ` Alex Khatskevich 2018-08-01 12:36 ` Vladislav Shpilevoy 2018-08-01 17:44 ` Alex Khatskevich 2018-08-02 11:51 ` Vladislav Shpilevoy 2018-07-30 8:56 ` [tarantool-patches] [PATCH 2/4] Refactor reloadable fiber AKhatskevich 2018-07-30 11:55 ` [tarantool-patches] " Vladislav Shpilevoy 2018-07-31 11:24 ` Alex Khatskevich 2018-07-31 11:30 ` Alex Khatskevich 2018-08-01 11:54 ` Vladislav Shpilevoy 2018-07-30 8:56 ` [tarantool-patches] [PATCH 3/4] tests: separate bootstrap routine to a lua_libs AKhatskevich 2018-08-01 12:03 ` [tarantool-patches] " Vladislav Shpilevoy 2018-07-30 8:56 ` [tarantool-patches] [PATCH 4/4] Introduce storage reload evolution AKhatskevich 2018-07-30 11:55 ` [tarantool-patches] " Vladislav Shpilevoy 2018-07-31 11:29 ` Alex Khatskevich 2018-07-31 11:33 ` Alex Khatskevich 2018-08-01 12:36 ` Vladislav Shpilevoy 2018-08-01 18:09 ` Alex Khatskevich 2018-08-02 11:40 ` Vladislav Shpilevoy 2018-08-02 11:46 ` Vladislav Shpilevoy 2018-08-06 10:59 ` Alex Khatskevich 2018-08-06 15:36 ` Vladislav Shpilevoy 2018-08-06 16:08 ` Alex Khatskevich 2018-08-06 17:18 ` Vladislav Shpilevoy 2018-08-07 9:14 ` Alex Khatskevich 2018-08-08 10:35 ` Vladislav Shpilevoy 2018-08-01 14:07 ` [tarantool-patches] [PATCH] Check self arg passed for router objects AKhatskevich
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=4a8e9e20-561d-6896-ea8c-8517add2bc50@tarantool.org \ --to=v.shpilevoy@tarantool.org \ --cc=avkhatskevich@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='[tarantool-patches] Re: [PATCH 1/4] Fix races related to object outdating' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox