Skip to content

Commit aff76fc

Browse files
ryaneorthpintsized
authored andcommitted
Fix issue in sentinel logic for gathering healthy slaves
1 parent 4a208ec commit aff76fc

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/resty/redis/sentinel.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ function _M.get_slaves(sentinel, master_name)
3939
host[slave[i]] = slave[i + 1]
4040
end
4141

42-
if host["master-link-status"] == "ok" then
42+
local master_link_status_ok = host["master-link-status"] == "ok"
43+
local is_down = host["flags"] and (string.find(host["flags"],"s_down")
44+
or string.find(host["flags"],"o_down")
45+
or string.find(host["flags"],"disconnected"))
46+
if master_link_status_ok and not is_down then
4347
host.host = host.ip -- for parity with other functions
4448
tbl_insert(hosts, host)
4549
end

0 commit comments

Comments
 (0)