killme2008 / xmemcached

High performance, easy to use multithreaded memcached client in java.
http://fnil.net/xmemcached
Apache License 2.0
756 stars 280 forks source link

Do not collapse multiple servers when they resolve to the same IP #78

Open saschat opened 6 years ago

saschat commented 6 years ago

When I start XMemcached with multiple server strings that point to the same IP XMemcached will just create a single session.

For example if I have DNS-1 pointing to server-1 and DNS-2 also pointing to server-1 XMemcached will create one session to server-1. If I later point DNS-2 to server-2 and restart server-1 to bump off the connection XMemcached will only heal the session to server-1 but not create one to server-2.

The reason this is important is flexibility. I need to be able to reconfigure servers without having to change the client configuration or restart the client.

saschat commented 6 years ago

This is because the XMemcachedBuilder stores the addresses in protected Map<InetSocketAddress, InetSocketAddress> addressMap = new LinkedHashMap<InetSocketAddress, InetSocketAddress>();. Two InetSocketAddress with different hostnames that resolve to the same IP hash to the same value.