top 一下,看到openresty有一个进程跑满了,而这个进程是旧进程遗留下来的,gdb栈信息一直卡在ctype_raw 这个函数
栈信息如下:
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
0x00007fcc3c579371 in ctype_get (id=<optimized out>, cts=<optimized out>) at lj_ctype.h:402
402 return &cts->tab[ctype_check(cts, id)];
#0 0x00007fcc3c579371 in ctype_get (id=<optimized out>, cts=<optimized out>) at lj_ctype.h:402
#1 ctype_child (ct=<optimized out>, cts=<optimized out>) at lj_ctype.h:413
#2 ctype_raw (id=<optimized out>, cts=<optimized out>) at lj_ctype.h:420
#3 lj_ccall_func (L=0x4177a770, cd=0x4018d138) at lj_ccall.c:1123
#4 0x00007fcc3c58d25b in lj_cf_ffi_meta___call (L=0x4177a770) at lib_ffi.c:230
#5 0x00007fcc3c5398da in lj_BC_FUNCC () from /usr/local/dcr-agent/luajit/lib/libluajit-5.1.so.2
#6 0x00000000004b2eae in ngx_http_lua_run_thread (L=0x40df2378, r=0x7fcc39dedef0, ctx=0x7fcc3cffc060, nrets=0) at ../ngx_lua-0.10.7/src/ngx_http_lua_util.c:1005
#7 0x00000000004b4b0e in ngx_http_lua_content_by_chunk (L=0x40df2378, r=0x7fcc39dedef0) at ../ngx_lua-0.10.7/src/ngx_http_lua_contentby.c:120
#8 0x00000000004b4ded in ngx_http_lua_content_handler_file (r=0x7fcc39dedef0) at ../ngx_lua-0.10.7/src/ngx_http_lua_contentby.c:284
#9 0x00000000004b47b2 in ngx_http_lua_content_handler (r=0x7fcc39dedef0) at ../ngx_lua-0.10.7/src/ngx_http_lua_contentby.c:222
#10 0x000000000044976c in ngx_http_core_content_phase (r=0x7fcc39dedef0, ph=0x7fcc39c16080) at src/http/ngx_http_core_module.c:1379
#11 0x00000000004443fd in ngx_http_core_run_phases (r=0x7fcc39dedef0) at src/http/ngx_http_core_module.c:856
#12 0x000000000044e491 in ngx_http_process_request (r=0x7fcc39dedef0) at src/http/ngx_http_request.c:1916
#13 0x000000000044f3b9 in ngx_http_process_request_line (rev=0x7fcc07dd93d0) at src/http/ngx_http_request.c:1027
#14 0x0000000000435c45 in ngx_event_process_posted (cycle=<optimized out>, posted=0x759a00 <ngx_posted_events>) at src/event/ngx_event_posted.c:33
#15 0x000000000043baeb in ngx_worker_process_cycle (cycle=0x194d9f0, data=<optimized out>) at src/os/unix/ngx_process_cycle.c:753
#16 0x000000000043a2a0 in ngx_spawn_process (cycle=0x194d9f0, proc=0x43bab0 <ngx_worker_process_cycle>, data=0x0, name=0x4fcd18 "worker process", respawn=-4) at src/os/unix/ngx_process.c:198
#17 0x000000000043b1b1 in ngx_start_worker_processes (cycle=0x194d9f0, n=4, type=-4) at src/os/unix/ngx_process_cycle.c:358
#18 0x000000000043c2f3 in ngx_master_process_cycle (cycle=0x194d9f0) at src/os/unix/ngx_process_cycle.c:243
#19 0x000000000041aacb in main (argc=1395310480, argv=<optimized out>) at src/core/nginx.c:371
死循环代码如下:
while (ctype_isattrib(ct->info)) ct = ctype_child(cts, ct);
我现在想知道是我的lua代码导致了死循环,还是lua代码缓存被异常清掉导致的。
我的业务代码大致如下,其中pcdn_info_tab.list是共享内存里的数据:
local list_tab = pcdn_info_tab.list
local result_tab = {}
for _, one_ip_info in ipairs(list_tab) do
repeat
if not one_ip_info.ip or not one_ip_info.sum or not one_ip_info.delay or not one_ip_info.timeout or not one_ip_info.nodata then
ngx.log(ngx.ERR, "leak some field:", cjson.encode(one_ip_info))
break
end
table.insert(result_tab, "scPcdnInfo\t".. one_ip_info.ip .. "\t" .. one_ip_info.sum .. "\t" .. one_ip_info.delay .. "\t" .. one_ip_info.timeout .. "\t" .. one_ip_info.nodata)
until true
end
if #result_tab == 0 then
ngx.exit(200)
else
ngx.say("monObj\tip\tsum\tdelay\ttimeout\tnodata\n" .. table.concat(result_tab, "\n"))
end
请大神解答。