lua entry thread aborted: runtime error resty/redis.lua:0: attempt to perform arithmetic on a table value

124 views
Skip to first unread message

Pahud Hsieh

unread,
Apr 22, 2014, 7:51:46 AM4/22/14
to open...@googlegroups.com
您好

我在每秒大約600-800個ngx_lua請求的時候會出現這樣的錯誤訊息。

版本目前是 ngx_openresty-1.5.11.1


 /opt/openresty/nginx/conf/lua/api/chat/send.lua:702: in function </opt/openresty/nginx/conf/lua/api/chat/send.lua:684>, context: ngx.timer
2014/04/22 19:40:24 [error] 17044#0: lua entry thread aborted: runtime error: /opt/openresty/lualib/resty/redis.lua:0: attempt to perform arithmetic on a table value
stack traceback
:
coroutine
0:
 
/opt/openresty/lualib/resty/redis.lua: in function 'rpush'


附上出錯的代碼,但是感覺應該是redis.lua 底層的報錯。

local function send_to_save (red, msg_key)
 
if debug then ngx.log(ngx.ERR,'[debug] send_to_save(rpush) with data='..msg_key) end
 
local res, err = red:rpush( red_prefix..':msg:to:save', msg_key )
 
if err then
 ngx
.log(ngx.ERR, '[debug] send_to_save(rpush) FAILED with data=',msg_key, 'err=',err)
 
end
end


請問有什麼辦法找出原因嗎?

thanks


Yichun Zhang (agentzh)

unread,
Apr 22, 2014, 2:55:11 PM4/22/14
to openresty
Hello!

On Tue, Apr 22, 2014 at 4:51 AM, Pahud Hsieh wrote:
> 我在每秒大約600-800個ngx_lua請求的時候會出現這樣的錯誤訊息。
> 版本目前是 ngx_openresty-1.5.11.1
> /opt/openresty/nginx/conf/lua/api/chat/send.lua:702: in function
> </opt/openresty/nginx/conf/lua/api/chat/send.lua:684>, context: ngx.timer
> 2014/04/22 19:40:24 [error] 17044#0: lua entry thread aborted: runtime
> error: /opt/openresty/lualib/resty/redis.lua:0: attempt to perform
> arithmetic on a table value

看起来像是触发了 LuaJIT 的 JIT 编译器里的某个 bug. 你能尝试一下最新的 OpenResty 1.5.12.1 RC3 版吗?

http://openresty.org/download/ngx_openresty-1.5.12.1rc3.tar.gz

这个版本里的 LuaJIT 包含了许多最新的 JIT 编译器里的 bug 修复。

多谢!
-agentzh

Pahud Hsieh

unread,
Apr 23, 2014, 5:04:59 AM4/23/14
to open...@googlegroups.com
Hello 

看起来像是触发了 LuaJIT 的 JIT 编译器里的某个 bug. 你能尝试一下最新的 OpenResty 1.5.12.1 RC3 版吗?

    http://openresty.org/download/ngx_openresty-1.5.12.1rc3.tar.gz

这个版本里的 LuaJIT 包含了许多最新的 JIT 编译器里的 bug 修复。

多谢!
-agentzh

已經升級上去了,還在觀察。

順帶問一下也許是同樣的問題

2014/04/23 16:40:38 [error] 29283#0: *53941 lua entry thread aborted: runtime error: /opt/openresty/nginx/conf/lua/api/foo/bar.lua:523: bad argument #1 to 'ipairs' (table expected, got boolean)
stack traceback
:
coroutine
0:
 
[C]: in function 'ipairs'


出現這樣的錯誤

我的代碼:

        if rev then
            res
, err        = red:zrevrangebyscore(zset , "("..e_lfts, 0, 'withscores', 'limit', 0, 10 )
       
else
            res
, err        = red:zrangebyscore(zset , "("..e_lfts, e_lts, 'withscores', 'limit', 0, 10 )
       
end


       
for k,v in ipairs(res) do


請問一下,對於 red:zrevrangebyscore 的回傳,什麼情況會res是boolean而不是table?

一般執行redis命令之後是否一律從err來判斷執行成功與否比較好?

例如

res, err = red:zrevrangebyscore(zset , "("..e_lfts, 0, 'withscores', 'limit', 0, 10 )

if err then
   ngx
.log(ngx.ERR, 'redis err: ',err)
else
 
-- 這裡開始處理restable內容
end


謝謝







Pahud Hsieh

unread,
Apr 23, 2014, 5:26:43 AM4/23/14
to open...@googlegroups.com

出現這樣的錯誤

我的代碼:

        if rev then
            res
, err        = red:zrevrangebyscore(zset , "("..e_lfts, 0, 'withscores', 'limit', 0, 10 )
       
else
            res
, err        = red:zrangebyscore(zset , "("..e_lfts, e_lts, 'withscores', 'limit', 0, 10 )
       
end


       
for k,v in ipairs(res) do



自問自答一下,是我帶入zrangebyscore的value type有問題造成的。

的確先檢查err會比較容易找到問題。
Reply all
Reply to author
Forward
0 new messages