lua-resty-mysql icon indicating copy to clipboard operation
lua-resty-mysql copied to clipboard

attempt to call local 'new_tab' (a table value)

Open Yahook opened this issue 8 years ago • 4 comments

Hello,

I get a strange error from time to time:

lua entry thread aborted: runtime error: /resty/mysql.lua:63: attempt to call local 'new_tab' (a table value)
stack traceback:
coroutine 0:
	[C]: in function 'require'

And after that this error:

2017/03/29 22:05:16 [error] 65691#0: *7148887 lua entry thread aborted: runtime error: search16.lua:1877: loop or previous error loading module 'resty.mysql'
stack traceback:
coroutine 0:
	[C]: in function 'require'

Of cource I load module only one time. I tried to load module at the beginning of the script - there is no difference. This error happens.

I use mysql.lua to work with sphinx db. Could you please help me to understand what I'm doing wrong?

Yahook avatar Mar 30 '17 01:03 Yahook

@Yahook Seems like you have a 3rd-party Lua module named table.new in your LuaJIT's search paths?

agentzh avatar Mar 30 '17 02:03 agentzh

table.new should be a standard Lua module provided by LuaJIT and the module itself is a Lua function instead of a table.

agentzh avatar Mar 30 '17 02:03 agentzh

Hello,

Thank you for your answer. I checked which modules I have:

[root@s2316 /opt/lua/resty]# grep -r new_tab /opt /opt/lua/resty/cookie.lua:local ok, new_tab = pcall(require, "table.new") /opt/lua/resty/cookie.lua: new_tab = function () return {} end /opt/lua/resty/cookie.lua:local _M = new_tab(0, 2) /opt/lua/resty/cookie.lua: local cookie_table = new_tab(0, n + 1) /opt/lua/resty/cookie.lua: return setmetatable({ _cookie = _cookie, set_cookie_table = new_tab(4, 0) }, /opt/lua/resty/mysql.lua:local ok, new_tab = pcall(require, "table.new") /opt/lua/resty/mysql.lua: new_tab = function (narr, nrec) return {} end /opt/lua/resty/mysql.lua:local converters = new_tab(0, 8) /opt/lua/resty/mysql.lua: local bytes = new_tab(len, 0) /opt/lua/resty/mysql.lua: local bytes = new_tab(len, 0) /opt/lua/resty/mysql.lua: local bytes = new_tab(n, 0) /opt/lua/resty/mysql.lua: local res = new_tab(0, 5) /opt/lua/resty/mysql.lua: local col = new_tab(0, 2) /opt/lua/resty/mysql.lua: row = new_tab(ncols, 0) /opt/lua/resty/mysql.lua: row = new_tab(0, ncols) /opt/lua/resty/mysql.lua: local cols = new_tab(field_count, 0) /opt/lua/resty/mysql.lua: local rows = new_tab(est_nrows or 4, 0) /opt/lua/resty/redis.lua:local ok, new_tab = pcall(require, "table.new") /opt/lua/resty/redis.lua: new_tab = function (narr, nrec) return {} end /opt/lua/resty/redis.lua:local _M = new_tab(0, 151) /opt/lua/resty/redis.lua: local vals = new_tab(n, 0); /opt/lua/resty/redis.lua: local req = new_tab(nargs + 1, 0) /opt/lua/resty/redis.lua: local array = new_tab(n, 0) /opt/lua/resty/redis.lua: self._reqs = new_tab(n or 4, 0) /opt/lua/resty/redis.lua: local vals = new_tab(nreqs, 0) /opt/lua/resty/redis.lua: local h = new_tab(0, n / 2) There is no table.new anywhere.

[root@s2316 ~]# luajit -v LuaJIT 2.0.4

Yahook avatar Mar 30 '17 10:03 Yahook

@Yahook You need LuaJIT 2.1. Better use OpenResty directly to avoid such problems. See https://openresty.org. Sorry, I do not have the time to diagnose your own setup issues.

agentzh avatar Mar 30 '17 20:03 agentzh