如果“重新加载”两次,nginx 就会挂起

如果“重新加载”两次,nginx 就会挂起

如果您执行“service nginx reload”2次(这也适用于执行“reload”的任何命令,例如systemctl reload nginx.service) - nginx 挂起并停止处理请求。

  • Ubuntu 20.10
  • nginx 版本:nginx/1.18.0(Ubuntu)

算法:

root@srv# service nginx reload
root@srv# service nginx reload
nginx.service is not active, cannot reload.
root@srv# service nginx status

● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: failed (Result: core-dump) since Mon 2021-03-22 12:18:00 MSK; 4s ago
       Docs: man:nginx(8)
    Process: 6747 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 6748 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 6798 ExecReload=/usr/sbin/nginx -g daemon on; master_process on; -s reload (code=exited, status=0/SUCCESS)
   Main PID: 6749 (code=dumped, signal=SEGV)
      Tasks: 0 (limit: 2281)
     Memory: 792.0K
     CGroup: /system.slice/nginx.service

Mar 22 12:18:00 vps-8355f791 systemd[1]: Reloaded A high performance web server and a reverse proxy server.
Mar 22 12:18:00 vps-8355f791 systemd[1]: nginx.service: Main process exited, code=dumped, status=11/SEGV
Mar 22 12:18:00 vps-8355f791 systemd[1]: nginx.service: Killing process 6750 (nginx) with signal SIGKILL.
Mar 22 12:18:00 vps-8355f791 systemd[1]: nginx.service: Killing process 6799 (nginx) with signal SIGKILL.
Mar 22 12:18:00 vps-8355f791 systemd[1]: nginx.service: Killing process 6750 (nginx) with signal SIGKILL.
Mar 22 12:18:00 vps-8355f791 systemd[1]: nginx.service: Killing process 6799 (nginx) with signal SIGKILL.
Mar 22 12:18:00 vps-8355f791 systemd[1]: nginx.service: Failed with result 'core-dump'.
Mar 22 12:18:00 vps-8355f791 systemd[1]: nginx.service: Unit process 6750 (nginx) remains running after unit stopped.
Mar 22 12:18:00 vps-8355f791 systemd[1]: nginx.service: Unit process 6799 (nginx) remains running after unit stopped.
Mar 22 12:18:03 vps-8355f791 systemd[1]: nginx.service: Unit cannot be reloaded because it is inactive.

日志控制:

Mar 22 12:18:00 vps-8355f791 kernel: nginx[6749]: segfault at 10 ip 00007f0ebffa5b33 sp 00007fffa313d360 error 4 in libperl.so.5.30.3[7f0ebff3d000+167000]
Mar 22 12:18:00 vps-8355f791 kernel: Code: 48 89 43 10 48 83 c4 18 5b 5d 41 5c 41 5d 41 5e 41 5f c3 0f 1f 40 00 0f b6 7f 30 48 c1 e8 03 48 29 f8 48 89 c3 74 89 48 8b 02 <4c> 8b 68 10 4d 85 ed 0f 84 28 01 00 00 0f b6 40 30 49 c1 ed 03 49
Mar 22 12:18:00 vps-8355f791 systemd[1]: nginx.service: Main process exited, code=dumped, status=11/SEGV
Mar 22 12:18:00 vps-8355f791 systemd[1]: nginx.service: Killing process 6750 (nginx) with signal SIGKILL.
Mar 22 12:18:00 vps-8355f791 systemd[1]: nginx.service: Killing process 6799 (nginx) with signal SIGKILL.
Mar 22 12:18:00 vps-8355f791 systemd[1]: nginx.service: Killing process 6750 (nginx) with signal SIGKILL.
Mar 22 12:18:00 vps-8355f791 systemd[1]: nginx.service: Killing process 6799 (nginx) with signal SIGKILL.
Mar 22 12:18:00 vps-8355f791 systemd[1]: nginx.service: Failed with result 'core-dump'.
Mar 22 12:18:00 vps-8355f791 systemd[1]: nginx.service: Unit process 6750 (nginx) remains running after unit stopped.
Mar 22 12:18:00 vps-8355f791 systemd[1]: nginx.service: Unit process 6799 (nginx) remains running after unit stopped.
Mar 22 12:18:03 vps-8355f791 systemd[1]: nginx.service: Unit cannot be reloaded because it is inactive.
Mar 22 12:18:08 vps-8355f791 sudo[6814]: pam_unix(sudo:session): session opened for user root by (uid=0)
Mar 22 12:18:08 vps-8355f791 sudo[6816]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/sbin/service nginx restart
Mar 22 12:18:08 vps-8355f791 sudo[6816]: pam_unix(sudo:session): session opened for user root by (uid=0)
Mar 22 12:18:08 vps-8355f791 systemd[1]: Starting A high performance web server and a reverse proxy server...
Mar 22 12:18:08 vps-8355f791 systemd[1]: Started A high performance web server and a reverse proxy server.
Mar 22 12:18:08 vps-8355f791 sudo[6816]: pam_unix(sudo:session): session closed for user root
Mar 22 12:18:08 vps-8355f791 sudo[6814]: pam_unix(sudo:session): session closed for user root

同时,如果你输入一次命令,一切都会顺利进行。但如果你快速输入两次命令,就会发生冲突。

答案1

问题原来出在 perl 5.30 上。 https://bugs.launchpad.net/ubuntu/+source/perl/+bug/1897561

多种解决方案:

  1. 禁用 nginx 模块 libnginx-mod-http-perl
  2. 更新 perl 至 5.32

相关内容