Skip to content

Commit 116a76b

Browse files
georgiy-belyaninTotktonada
authored andcommitted
connpool: do not wait in call() if all checked
This patch changes `connpool.call()` method. Previously, if there were instances satisfying the static requirements but not the dynamic ones the method waited until the timeout checking if they start to satisfy the requirements. It seems impractical. Existing dynamic options is unlikely to change during this small period of time. Let's not wait these instances and exit instead if no suitable instances have been found. Assume a cluster with two instances `i-001` and `i-002`. `i-001` is alive and RW. `i-002` is dead. Previous version of `connpool.call(<func>, <args>, {mode = 'ro'})` would wait in that case since it expected for an RO instance to appear. New version of `connpool.call(<func>, <args>, {mode = 'ro'})` just ends up with a "no candidates found" error. Part of tarantool#10330 NO_DOC=small change of an undocumented behavior, related will be added later NO_CHANGELOG=will be added later NO_TEST=related logic will be tested later in the patchset
1 parent f840bef commit 116a76b

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/box/lua/connpool.lua

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,12 @@ end
241241
--- This method connects to the specified instances and returns
242242
--- the set of successfully connected ones.
243243
---
244-
--- Specifying a callback accepting an instance name and returning
245-
--- a boolean value in `opts.any` changes the behavior to connect
246-
--- to multiple instances until there is at least one satisfying
247-
--- the condition or the timeout occurs.
244+
--- If a callback accepting an instance name and returning a
245+
--- boolean value is provided in `opts.any` the method connects
246+
--- to multiple instances and try to find one satisfying the
247+
--- callback. It lasts until all of the instances are known to
248+
--- be unsuitable (either failed or not satisfying the callback)
249+
--- or the timeout is reached.
248250
function pool_methods.connect_to_multiple(self, instances, opts)
249251
checks('table', 'table', {
250252
any = '?function',
@@ -291,10 +293,10 @@ function pool_methods.connect_to_multiple(self, instances, opts)
291293
if fun.iter(instances):any(opts.any) then
292294
break
293295
end
294-
else
295-
if fun.iter(instances):all(is_instance_checked) then
296-
break
297-
end
296+
end
297+
298+
if fun.iter(instances):all(is_instance_checked) then
299+
break
298300
end
299301

300302
self._connection_mode_update_cond:wait(delay)

0 commit comments

Comments
 (0)