Skip to content

Commit b26220f

Browse files
piotrppintsized
authored andcommitted
Always set keepalive for sentinel that correctly returned master's address
1 parent 7a9fa9c commit b26220f

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

lib/resty/redis/connector.lua

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -247,19 +247,17 @@ function _M.connect_via_sentinel(self, params)
247247
return nil, err
248248
end
249249

250+
sentnl:set_keepalive()
251+
250252
master.db = db
251253
master.password = password
252254

253255
local redis, err = self:connect_to_host(master)
254-
if redis then
255-
sentnl:set_keepalive()
256-
return redis, err
257-
else
258-
if role == "master" then
259-
return nil, err
260-
end
256+
if not redis then
257+
return nil, err
261258
end
262259

260+
return redis
263261
else
264262
-- We want a slave
265263
local slaves, err = get_slaves(sentnl, master_name)

0 commit comments

Comments
 (0)