[Tarantool-patches] [PATCH vshard 2/2] router: don't fallback RO to master right away

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Tue Dec 7 02:56:29 MSK 2021


Thanks for the review!

On 05.12.2021 18:53, Oleg Babin wrote:
> Thanks for your patch. See one comment below.
> 
> Also as I see CI is red on your branch. Is it related to your changes?

Yes, I didn't update .result file in one of the tests. Done now.

>> diff --git a/vshard/replicaset.lua b/vshard/replicaset.lua
>> index 174c761..93f210e 100644
>> --- a/vshard/replicaset.lua
>> +++ b/vshard/replicaset.lua
>> @@ -455,18 +455,25 @@ local function replicaset_template_multicallro(prefer_replica, balance)
>>                       return r
>>                   end
>>               end
>> -        elseif prefer_replica then
>> -            r = replicaset.replica
>> +        else
>> +            local start_r = replicaset.replica
>> +            r = start_r
>>               while r do
>> -                if r:is_connected() and r ~= master then
>> +                if r:is_connected() and (not prefer_replica or r ~= master) then
>>                       return r
>>                   end
>>                   r = r.next_by_priority
>>               end
>> -        else
>> -            r = replicaset.replica
>> -            if r and r:is_connected() then
>> -                return r
>> +            -- Iteration above could start not from the best prio replica.
>> +            -- Check the beginning of the list too.
>> +            for _, r in pairs(replicaset.priority_list) do
> 
> pairs can't be jitted (at least now until https://github.com/tarantool/tarantool/issues/6475).
> 
> Also pairs don't give any guarantees about iteration order. Could it be replaced with ipairs?

It can be. Replaced with ipairs on the branch.


More information about the Tarantool-patches mailing list