apisix icon indicating copy to clipboard operation
apisix copied to clipboard

bug: runtime error- attempt to perform arithmetic on a nil value

Open ali-mahdavi-mehr opened this issue 1 year ago • 2 comments

Current Behavior

We have encountered this error in APISIX, and we are unsure when it occurs. Additionally, we do not know which library calls this function, but an error has occurred for us occasionally, not always. Please let us know the reason for this error and how to prevent it. Thank you

Expected Behavior

129 => local milliseconds = tonumber(seconds) * 1000 (in lua-resty-core)

I think that wherever this function is called, it sends a nil value as "seconds".

Error Logs

[error]: * lua user thread aborted: runtime error: /usr/local/openresty/lualib/ngx/semaphore.lua:129: attempt to perform arithmetic on a nil value

Steps to Reproduce

We couldn't figure out where and when in the code this function is being called. and we do not use this library in any of our plugins

Environment

  • APISIX version (run apisix version):3.8.0

ali-mahdavi-mehr avatar Feb 07 '24 11:02 ali-mahdavi-mehr

please update this thread when you encounter any clues on how to reproduce this.

shreemaan-abhishek avatar Feb 08 '24 16:02 shreemaan-abhishek

please update this thread when you encounter any clues on how to reproduce this.

2024/07/22 06:27:39 [error] 58#58: *29775831 lua user thread aborted: runtime error: /usr/local/openresty/lualib/ngx/semaphore.lua:129: attempt to perform arithmetic on a nil value stack traceback: coroutine 0: /usr/local/openresty/lualib/ngx/semaphore.lua: in function 'wait' /usr/local/apisix//deps/share/lua/5.1/resty/etcd/v3.lua:510: in function 'refresh_jwt_token' /usr/local/apisix//deps/share/lua/5.1/resty/etcd/v3.lua:205: in function 'keepalive' /usr/local/apisix/apisix/core/etcd.lua:515: in function 'keepalive' /usr/local/apisix/apisix/plugins/server-info.lua:221: in function 'report' /usr/local/apisix/apisix/plugins/server-info.lua:292: in function </usr/local/apisix/apisix/plugins/server-info.lua:287> coroutine 1: [C]: in function 'thread_wait' /usr/local/apisix/apisix/timers.lua:52: in function </usr/local/apisix/apisix/timers.lua:32> [C]: in function 'pcall' /usr/local/apisix/apisix/core/timer.lua:40: in function </usr/local/apisix/apisix/core/timer.lua:36> [C]: in function 'pcall' /usr/local/apisix/apisix/core/timer.lua:63: in function </usr/local/apisix/apisix/core/timer.lua:56>, context: ngx.timer 2024/07/22 06:27:39 [error] 58#58: *29775831 [lua] timers.lua:54: failed to wait threads, context: ngx.timer

The phenomenon does not occur regularly, sometimes it takes a few hours, sometimes a few days

johnxiaohe avatar Jul 22 '24 10:07 johnxiaohe