Improve LoadBalancer caught up replica search
In the LoadBalancer#all_caught_up?
method, we are checking if all hosts have caught up to the given transaction write location.
This will query each replica on each request in order to check if all hosts have caught up to the given transaction write location...
Since all replicas are not synced at the same time, it could happen that we decided to stick to the primary, only because one of the replicas was out of date, but others could still be used. (We should probably add metric/track this to see how often it happens.)
We could probably improve this since we cannot scale very well with the number of replicas.
# Returns true if all hosts have caught up to the given transaction write location.
def all_caught_up?(location)
@host_list.hosts.all? { |host| host.caught_up?(location) }
end
Edited by Aleksei Lipniagov