【1】问题现象

(1)本地openresty系统

(2)报错信息

2019/09/10 08:13:55 [error] 2385#2385: *4 lua entry thread aborted: runtime error: /usr/local/lib/ubcservd/bin/../work/bill_timer.lua:1647: attempt to concatenate global 'value' (a nil value)

(3)分析原因

value变量为nil值的场景预先没有考虑到,导致连接字符串时失败。

(4)解决(容错)方案

打印value值时,增加nil值的判断。如下:

ngx.log(ngx.ERR, 'todo and print value: ' .. (value or 'nil'))

【2】问题追思

如上异常,出现过"lua entry thread aborted"以后,这个worker process(即id为2385)到底还存活吗?

注意,这里所谓的存活是相对于C++程序的空指针导致应用程序异常崩溃而言。

模拟场景,分析过程如下:

(1)具体思路:

设计两个定时器,分别设置不同的时间间隔(第一个时间间隔120s短于第二个180s),启动nginx系统:

当第一个定时器执行异常(如上错误)后,观察第二个定时器是否可以正常执行。

(2)源码如下:

[1] 配置文件:

nginx.conf,如下:

worker_processes  ;
user  root;

events
{
    worker_connections  ;
}

http
{

    default_type  application/octet-stream;

    sendfile        on;

    send_timeout ;
    keepalive_timeout  ;

    lua_package_path  "/usr/local/lib/ubcservd/lualib/?.lua;;";

    lua_package_cpath  "/usr/local/lib/ubcservd/lualib/?.so;;";

    init_worker_by_lua_file work/bill_timer.lua;

}

[2] 定时器文件:

bill_timer.lua,如下:

    local new_timer = ngx.timer.at

    local function timer_test_one(permature)
        if not premature then
            ngx.log(ngx.ERR, "into timer_test_one print value " .. value)

            , timer_test)
            if not ok then
                ngx.log(ngx.ERR, "failed to create timer_test_one timer : ", err)
            else
                ngx.log(ngx.ERR, ')
            end
        end
    end

    local function timer_test_two(permature)
        if not premature then
            ngx.log(ngx.ERR, "into timer_test_two print ")

            , timer_test_two)
            if not ok then
                ngx.log(ngx.ERR, "failed to create timer_test_two timer : ", err)
            else
                ngx.log(ngx.ERR, ')
            end
        end
    end

     == ngx.worker.id() then
        , timer_test_one)
        if not ok then
            ngx.log(ngx.ERR, "failed to create timer_test_one timer : " .. err)
        else
            ngx.log(ngx.ERR, ')
        end

        , timer_test_two)
        if not ok then
            ngx.log(ngx.ERR, "failed to create timer_test_two timer : " .. err)
        else
            ngx.log(ngx.ERR, ')
        end
    end

[3] 启动nginx系统

成功启动,创建3个worker process,如下图:

[4] 日志分析

第一个定时器执行异常中止错误信息,立即观察worker进程情况:

进程id值为2869仍然存在,安然无恙。

第二个定时器执行正常打印信息,所有日志,如下图:

综上所述:“thread aborted” 并非崩溃,仅仅只是当前函数执行失败中止,此函数其余语句不会再执行。

Good Good Study, Day Day Up.

顺序 选择 循环 总结

openresty 报错:lua entry thread aborted: runtime error的更多相关文章

  1. lua entry thread aborted: runtime error: /usr/../process.lua:448: attempt to concatenate field 'np_sum_duration' (a userdata value)

    [1]问题场景原代码 引起问题的原代码,访问数据库,汇总数据后,使用汇总结果报异常: local function amount_sum_fee(cycleid) local select_produ ...

  2. 【Azure App Service】C#下制作的网站,所有网页本地测试运行无误,发布至Azure之后,包含CHART(图表)的网页打开报错,错误消息为 Runtime Error: Server Error in '/' Application

    问题描述 C#下制作的网站,所有网页本地测试运行无误,发布至Azure之后,包含CHART(图表)的网页打开报错,错误消息为 Runtime Error: Server Error in '/' Ap ...

  3. 【hibernate postgresql】注解@TypeDef/@Enumerated/数据库字段gender为枚举类型,从前台接受到实体后进行保存报错:org.postgresql.util.PSQLException: ERROR: column "gender" is of type gender but expression is of type character varying

    数据库字段gender为枚举类型,从前台接受到实体后进行保存报错:org.postgresql.util.PSQLException: ERROR: column "gender" ...

  4. 安装php时,make步骤报错make: *** [ext/gd/gd.lo] Error 1

    安装PHP时,make步骤报错make: *** [ext/gd/gd.lo] Error 1 /usr/local/src/LAMP+memcahed+catci/php-5.4.0/ext/gd/ ...

  5. windows 8 安装 oracle 11g 报错:command line option syntax error,type command/? for help

    windows 8 安装 oracle 11g 报错:command line option syntax error,type command/? for help 在windows8操作系统上安装 ...

  6. python——报错ImportError:DLL load failed with error code -1073741795的解决方式

    python中导入一个包,import cv2总是报错'ImportError:DLL load failed with error code -1073741795',报错形式: 网上找了好久的解决 ...

  7. 【Linux基础】mount报错:mount.nfs: Remote I/O error

    问题描述:mount 报错:mount.nfs: Remote I/O error 挂载时需要指明版本,由于NFS服务器有多个版本,V2.V3.V4.而且各版本同时运行,因此挂载时需要说明版本号. 由 ...

  8. eclipse项目无故报错,markers信息为An error occurred while filtering resources

    eclipse项目无故报错,markers信息为An error occurred while filtering resources 描述:eclipse项目和resource文件上有红色的叉,其m ...

  9. CentOS6.5 重启网络报错:Bringing up interface eth0: Error: Connection activation failed: Device not managed by NetworkManager or unavailable

    CentOS6.5 重启网络报错: Bringing up interface eth0: Error: Connection activation failed: Device not manage ...

随机推荐

  1. jvm默认的并行垃圾回收器和G1垃圾回收器性能对比

    http://www.importnew.com/13827.html 参数如下: JAVA_OPTS="-server -Xms1024m -Xmx1024m -Xss256k -XX:M ...

  2. ThreadPoolTaskExecutor学习

    1. ThreadPoolTaskExecutor学习 1.1. 前言 我们知道一般创建线程池,我们都用ThreadPoolExecutor,但实际上Spring它也对该线程池做了一层封装,他就是Th ...

  3. js中对象字面量

    一.对象字面量语法 var person={ name:'小王', age:18, _pri:233 } 成员名称的单引号不是必须的 最后一个成员结尾不要用逗号,不然在某些浏览器中会抛出错误 成员名相 ...

  4. 高性能TcpServer(C#) - 6.代码下载

    高性能TcpServer(C#) - 1.网络通信协议 高性能TcpServer(C#) - 2.创建高性能Socket服务器SocketAsyncEventArgs的实现(IOCP) 高性能TcpS ...

  5. linux ssh免密

    1.ssh-keygen -t rsa 生产密钥 2.ssh-copy-id 192.168.44.10 发布密钥  

  6. 深入解读Linux进程调度Schedule【转】

    转自:https://blog.csdn.net/Vince_/article/details/88982802 版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文 ...

  7. 分母为0的坑(float)

    分母不能为0 对于int 类型,如果分母为0,在程序运行时,会报错. 而对于float 类型,如果分母为0,则不会报错,而是会返回一个infinity(无穷大),也就是NAN. 因为除一个无穷小的数, ...

  8. Nginx 初步认识

    序言 Nginx是lgor Sysoev为俄罗斯访问量第二的rambler.ru站点设计开发的.从2004年发布至今,凭借开源的力量,已经接近成熟与完善. Nginx功能丰富,可作为HTTP服务器,也 ...

  9. lf 前后端分离 (4) 价格策略

    一.价格策略 价格策略就是通过前端发送要购买的课程以及价格策略来找出表关联的字段返回客户端 通过contenttype 属性 找到课程所有的价格策略 for prcie_policy in cours ...

  10. Appium+python自动化(二)- 环境搭建—下(超详解)

    简介 宏哥的人品还算说得过去,虽然很久没有搭建环境了,但是换了新电脑设备,一气呵成,将android的测试开发环境已经搭建准备完毕.上一篇android测试开发环境已经准备好, 那么接下来就是appi ...