zwjzxh520 opened a new issue #4869:
URL: https://github.com/apache/apisix/issues/4869


   ### Issue description
   
   依照 api-breaker 自己编写了一个插件,将计数器放到redis中,但是发现运行的时候一直报以下错误:
   ```
   2021/08/20 16:46:14 [error] 45#45: *2067 failed to run log_by_lua*: 
/usr/local/apisix/apisix/patch.lua:315: API disabled in the context of 
log_by_lua*
   stack traceback:
        [C]: in function 'original_tcp'
        /usr/local/apisix/apisix/patch.lua:315: in function 'tcp'
        /usr/local/openresty/lualib/resty/redis.lua:63: in function 'redis_new'
        /usr/local/apisix/apisix/plugins/sdp-api-breaker.lua:131: in function 
'new_redis'
        /usr/local/apisix/apisix/plugins/sdp-api-breaker.lua:239: in function 
'phase_func'
        /usr/local/apisix/apisix/plugin.lua:679: in function 'common_phase'
        /usr/local/apisix/apisix/init.lua:681: in function 'http_log_phase'
   ```
   
   报错相关代码如下:
   
![image](https://user-images.githubusercontent.com/2184202/130379529-2eeba431-0b9f-460e-9af7-fdf9951e845c.png)
   
   ```lua
   function _M.log(conf, ctx)
       local redis_util, err = new_redis(conf)
       if redis_util == nil then
           core.log.error("redis init failed at _M.log, err: ", err)
           return
       end
       local unhealthy_key = gen_unhealthy_key(ctx)
       local healthy_key = gen_healthy_key(ctx)
       local upstream_status = core.response.get_upstream_status(ctx)
   ```
   
   请帮忙找找解决办法,谢谢大家了~
   
   ### Environment
   
   - apisix version (cmd: `apisix version`):      **2.8**
   - OS (cmd: `uname -a`):   **alpine docker**
   - OpenResty / Nginx version (cmd: `nginx -V` or `openresty -V`):   **nginx 
version: openresty/1.19.3.1**
   - etcd version, if have (cmd: run `curl 
http://127.0.0.1:9090/v1/server_info` to get the info from server-info API):   
**3.4.0**
   - apisix-dashboard version, if have:
   - luarocks version, if the issue is about installation (cmd: `luarocks 
--version`):
   


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to