The alphabetical order of HostAndPort entries is significant in targeting hedged reads.
But the order we use doesn't seem proper, as it's relying on the HostAndPort::toString.
if (targetHostsInAlphabeticalOrder) { // Sort the target hosts by host names. std::sort(request.target.begin(), request.target.end(), [](const HostAndPort& target1, const HostAndPort& target2) { return target1.toString() < target2.toString(); }); }
I can see a few problems with this.
- DNS is case-insensitive, but this sort is not.
- IPv6 addresses start with a "[", an ASCII character that falls between the A-Z and a-Z character ranges, so a hybrid IPv6/IPv4 set will I suppose end up with a the IPv4 addrs ordered with the uppercase hosts, then ALL the IPv6 hosts, and then the lowercase hosts. This is definitely not the intent of the sort.
- It's expensive to compute toString on each of the NlogN comparisons of a sort.