gy09535 edited a comment on issue #2899:
URL: https://github.com/apache/apisix/issues/2899#issuecomment-737650987


   Fore every auth retch,  they will do 32 times fetch from this code
   ```
    while not exiting() and self.running and i <= 32 do
           i = i + 1
   ```
   
   I think this "ok" var will always true, if we do auth fail, and it can not 
sleep 3s. 
   
   ```
    if not ok then
               log.error("failed to fetch data from etcd: ", err, ", ",
                         tostring(self))
               ngx_sleep(3)
               break
           end
   ```
   It will sleep 0.5 s  from this code 
   ```
               if err then
                   if err ~= "timeout" and err ~= "Key not found"
                       and self.last_err ~= err then
                       log.error("failed to fetch data from etcd: ", err, ", ",
                                 tostring(self))
                   end
   
                   if err ~= self.last_err then
                       self.last_err = err
                       self.last_err_time = ngx_time()
                   else
                       if ngx_time() - self.last_err_time >= 30 then
                           self.last_err = nil
                       end
                   end
                   ngx_sleep(0.5)
   ```
   they are 16 batch job in on worker, this confused me ,it should be 8. 
   ```
   2020/12/03 11:17:26 [warn] 44375#0: *4 [lua] config_etcd.lua:468: begin to 
statistics call count for auto fetch,key:/apisix/routes, context: ngx.timer
   2020/12/03 11:17:26 [warn] 44375#0: *6 [lua] config_etcd.lua:468: begin to 
statistics call count for auto fetch,key:/apisix/ssl, context: ngx.timer
   2020/12/03 11:17:26 [warn] 44375#0: *8 [lua] config_etcd.lua:468: begin to 
statistics call count for auto fetch,key:/apisix/global_rules, context: 
ngx.timer
   2020/12/03 11:17:26 [warn] 44375#0: *10 [lua] config_etcd.lua:468: begin to 
statistics call count for auto fetch,key:/apisix/services, context: ngx.timer
   2020/12/03 11:17:26 [warn] 44375#0: *12 [lua] config_etcd.lua:468: begin to 
statistics call count for auto fetch,key:/apisix/proto, context: ngx.timer
   2020/12/03 11:17:26 [warn] 44375#0: *14 [lua] config_etcd.lua:468: begin to 
statistics call count for auto fetch,key:/apisix/plugin_metadata, context: 
ngx.timer
   2020/12/03 11:17:26 [warn] 44375#0: *16 [lua] config_etcd.lua:468: begin to 
statistics call count for auto fetch,key:/apisix/consumers, context: ngx.timer
   2020/12/03 11:17:26 [warn] 44375#0: *18 [lua] config_etcd.lua:468: begin to 
statistics call count for auto fetch,key:/apisix/upstreams, context: ngx.timer
   2020/12/03 11:17:26 [warn] 44372#0: *21 [lua] init.lua:262: 
sync_local_conf_to_etcd(): sync local conf to etcd, context: ngx.timer
   2020/12/03 11:17:26 [warn] 44372#0: *24 [lua] config_etcd.lua:468: begin to 
statistics call count for auto fetch,key:/apisix/routes, context: ngx.timer
   2020/12/03 11:17:26 [warn] 44372#0: *26 [lua] config_etcd.lua:468: begin to 
statistics call count for auto fetch,key:/apisix/ssl, context: ngx.timer
   2020/12/03 11:17:26 [warn] 44372#0: *28 [lua] config_etcd.lua:468: begin to 
statistics call count for auto fetch,key:/apisix/global_rules, context: 
ngx.timer
   2020/12/03 11:17:26 [warn] 44372#0: *30 [lua] config_etcd.lua:468: begin to 
statistics call count for auto fetch,key:/apisix/services, context: ngx.timer
   2020/12/03 11:17:26 [warn] 44372#0: *32 [lua] config_etcd.lua:468: begin to 
statistics call count for auto fetch,key:/apisix/proto, context: ngx.timer
   2020/12/03 11:17:26 [warn] 44372#0: *34 [lua] config_etcd.lua:468: begin to 
statistics call count for auto fetch,key:/apisix/plugin_metadata, context: 
ngx.timer
   2020/12/03 11:17:26 [warn] 44372#0: *36 [lua] config_etcd.lua:468: begin to 
statistics call count for auto fetch,key:/apisix/consumers, context: ngx.timer
   2020/12/03 11:17:26 [warn] 44372#0: *38 [lua] config_etcd.lua:468: begin to 
statistics call count for auto fetch,key:/apisix/upstreams, context: ngx.timer
   ```
   for one worker, they are 16*2=32 requests (max) in one second , why we try 
to fetch 32 times in on auth fetch, I think we should remove it.
   ```
    while not exiting() and self.running and i <= 32 do
           i = i + 1
   ```
   
   And I think we should sleep for more times when fetch is error.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to