upyun / slardar

Updating your upstream list and run lua scripts without reloading Nginx.
493 stars 111 forks source link

Can not failover up to good server if one server down with consistent_hash method #6

Open xiaoxuanzi opened 7 years ago

xiaoxuanzi commented 7 years ago

Hi: I found a error: upstream test have two servers:

upstream test{ server 192.168.46.111:80; server 192.168.46.110:80; }

if upstream use consistent_hash method, if one of upstream server is down, this method can not failover up to good server.

I guess Problem may be in the function of try_cluster_consistent_hash:

_
-- try backup node local hash_backup_node = cls.hash_backup_node or 1 local q = (p + hash % hash_backup_node + 1) % server_len + 1 if p ~= q then local try = cls.try or #cls.servers res, err = base.tryserver(skey, ups, cls.servers[q], callback, args, try - 1) if res then return res end end

It so?

I am anticipating your reply.

yejingx commented 7 years ago

Please upgrade lua-resty-checkups to the newest version and try again. This problem seems to have been fixed in the new version.

Related issue: https://github.com/upyun/lua-resty-checkups/issues/3

xiaoxuanzi commented 7 years ago

thanks a lot