Skip to content

bug: config_util.lua:71: attempt to call local 'f' (a nil value) #7633

Description

@BansheeLW

Current Behavior

The service is configured with a health check. When the upstream node changes and the concurrent request is bright, there will be a large number of 500 errors(lua entry thread aborted because function 'f' is nil)

Expected Behavior

The function 'f' should not be nil, the request should be completed normally

Error Logs

The error log is found as follows:
2022/08/08 10:29:46 [error] 46#46: *144287093 lua entry thread aborted: runtime error: /usr/local/apisix/apisix/core/config_util.lua:71: attempt to call local 'f' (a nil value)
stack traceback:
coroutine 0:
/usr/local/apisix/apisix/core/config_util.lua: in function 'cancel_clean_handler'
/usr/local/apisix/apisix/upstream.lua:119: in function 'fetch_healthchecker'
/usr/local/apisix/apisix/upstream.lua:327: in function 'set_upstream'
/usr/local/apisix/apisix/init.lua:515: in function 'http_access_phase'
access_by_lua(nginx.conf:253):2: in main chunk, client: 172.31.xx.xx, server: _, request: "GET xxxxxxx

According to the error message, find the location of the error code:
file path: apisix/core/config_util.lua

function _M.cancel_clean_handler(item, idx, fire)
local f = item.clean_handlers[idx]
core_tab.remove(item.clean_handlers, idx)
if fire then
f(item)
end
end

Steps to Reproduce

  1. Install apisix to EKS using the helm package
  2. Service discovery using kubernetes
  3. Routed services enable health checks
  4. Initiate concurrent requests, no such error message appears
  5. Adjust (increase or decrease) upstream nodes, and then initiate concurrent requests, a large number of such error logs appear, and the requester receives a large number of 500 errors

Environment

  • APISIX version (run apisix version):2.14.1
  • Operating system (run uname -a): Linux apisix-58d87884d-l4qkw 5.4.129-63.229.amzn2.x86_64 change: added doc of how to load plugin. #1 SMP Tue Jul 20 21:22:08 UTC 2021 x86_64 Linux
  • OpenResty / Nginx version (run openresty -V or nginx -V): nginx version: openresty/1.19.9.1
  • etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info):3.4.0
  • APISIX Dashboard version, if relevant:2.13.0
  • LuaRocks version, for installation issues (run luarocks --version): 3.8.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    checkingcheck first if this issue occurred

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions