@@ -97,7 +97,7 @@ local function split(s, delimiter)
97
97
end
98
98
99
99
local function try_hosts_slots (self , serv_list )
100
- local start_time = ngx .req . start_time ()
100
+ local start_time = ngx .now ()
101
101
local errors = {}
102
102
local config = self .config
103
103
if # serv_list < 1 then
@@ -197,12 +197,19 @@ function _M.fetch_slots(self)
197
197
local serv_list = self .config .serv_list
198
198
local serv_list_cached = slot_cache [self .config .name .. " serv_list" ]
199
199
200
- local serv_list_combined = {}
200
+ local serv_list_combined
201
201
202
- -- if a cached serv_list is present, use it
202
+ -- if a cached serv_list is present, start with that
203
203
if serv_list_cached then
204
204
serv_list_combined = serv_list_cached .serv_list
205
+
206
+ -- then append the serv_list from config, in the event that the entire
207
+ -- cached serv_list no longer points to anything usable
208
+ for _ , s in ipairs (serv_list ) do
209
+ table_insert (serv_list_combined , s )
210
+ end
205
211
else
212
+ -- otherwise we bootstrap with our serv_list from config
206
213
serv_list_combined = serv_list
207
214
end
208
215
@@ -668,20 +675,21 @@ function _M.commit_pipeline(self)
668
675
config .read_timeout or DEFAULT_READ_TIMEOUT )
669
676
local ok , err = redis_client :connect (ip , port , self .config .connect_opts )
670
677
671
- local authok , autherr = check_auth (self , redis_client )
672
- if autherr then
673
- return nil , autherr
674
- end
678
+ if ok then
679
+ local authok , autherr = check_auth (self , redis_client )
680
+ if autherr then
681
+ return nil , autherr
682
+ end
675
683
676
- if slave then
677
- -- set readonly
678
- local ok , err = redis_client :readonly ()
679
- if not ok then
680
- self :refresh_slots ()
681
- return nil , err
684
+ if slave then
685
+ -- set readonly
686
+ local ok , err = redis_client :readonly ()
687
+ if not ok then
688
+ self :refresh_slots ()
689
+ return nil , err
690
+ end
682
691
end
683
- end
684
- if ok then
692
+
685
693
redis_client :init_pipeline ()
686
694
for i = 1 , # reqs do
687
695
local req = reqs [i ]
0 commit comments