[tarantool-patches] Re: [PATCH 1/4] Fix races related to object outdating
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Mon Jul 30 20:50:52 MSK 2018
On 30/07/2018 19:46, Alex Khatskevich wrote:
>
>>> 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.
More information about the Tarantool-patches
mailing list