3rd-Eden / memcached

A fully featured Memcached client build on top of Node.js. Build with scaling in mind so it will support Memcached clusters and consistent hashing.
MIT License
1.31k stars 276 forks source link

Failover Servers not working when only 1 master server #364

Open ChinmoyMahapatra opened 3 years ago

ChinmoyMahapatra commented 3 years ago

Failover servers work fine if we have more than 1 master node but not working for 1 master node. Replacing the server upon failure just replaces the servers in hashring and not in memcached (this.servers), so the below logic seems to be wrong.

// try to find the correct server for this query if (!server) { // no need to do a hashring lookup if we only have one server assigned to // us if (this.servers.length === 1) { server = this.servers[0]; // -> this seems to be wrong since the this.servers is not getting updated upon servers swap } else { if (redundancy && queryRedundancy) { redundancy = this.HashRing.createRange(query.key, (this.redundancy + 1), true); server = redundancy.shift(); } else { server = this.HashRing.get(query.key); } } }