Nginx reload, выедает CPU
Serge Negodyuck
petr at petrovich.kiev.ua
Tue Aug 27 14:35:22 UTC 2013
Как только я посылаю nginx сигнал HUP (или nginx -s reload), процессы
в состоянии "nginx: worker process is shutting down (nginx)" начинают
кушать весь доступный процессор.
Если подсоединиться к такому процессу отладчиком:
(gdb) bt
#0 0x0000000801656d5c in kevent () from /lib/libc.so.7
#1 0x00000000004370c0 in ngx_kqueue_process_events (cycle=0x801cf5050,
timer=18446744073709551615, flags=0) at
src/event/modules/ngx_kqueue_module.c:537
#2 0x000000000042923c in ngx_process_events_and_timers
(cycle=0x801cf5050) at src/event/ngx_event.c:249
#3 0x00000000004342e3 in ngx_worker_process_cycle (cycle=0x801cf5050,
data=0x2) at src/os/unix/ngx_process_cycle.c:807
#4 0x0000000000431879 in ngx_spawn_process (cycle=0x801cf5050,
proc=0x434180 <ngx_worker_process_cycle>, data=0x2, name=0x4b7dd3
"worker process", respawn=-3) at src/os/unix/ngx_process.c:198
#5 0x0000000000433576 in ngx_start_worker_processes
(cycle=0x801cf5050, n=8, type=-3) at
src/os/unix/ngx_process_cycle.c:362
#6 0x0000000000432d79 in ngx_master_process_cycle (cycle=0x801cf5050)
at src/os/unix/ngx_process_cycle.c:136
#7 0x0000000000406ac3 in main (argc=1, argv=0x7fffffffdda8) at
src/core/nginx.c:412
(gdb) backtrace full
#0 0x0000000801656d5c in kevent () from /lib/libc.so.7
No symbol table info available.
#1 0x00000000004370c0 in ngx_kqueue_process_events (cycle=0x801cf5050,
timer=18446744073709551615, flags=0) at
src/event/modules/ngx_kqueue_module.c:537
events = 7227840
n = 0
i = 34426922320
instance = 140737488345392
level = 4370853
err = 0
ev = (ngx_event_t *) 0x804012550
queue = (ngx_event_t **) 0x804012a90
ts = {tv_sec = 35128236032, tv_nsec = 0}
tp = (struct timespec *) 0x0
#2 0x000000000042923c in ngx_process_events_and_timers
(cycle=0x801cf5050) at src/event/ngx_event.c:249
flags = 0
timer = 18446744073709551615
delta = 1377613229768
#3 0x00000000004342e3 in ngx_worker_process_cycle (cycle=0x801cf5050,
data=0x2) at src/os/unix/ngx_process_cycle.c:807
worker = 2
i = 32768
c = (ngx_connection_t *) 0x82d000000
#4 0x0000000000431879 in ngx_spawn_process (cycle=0x801cf5050,
proc=0x434180 <ngx_worker_process_cycle>, data=0x2, name=0x4b7dd3
"worker process", respawn=-3) at src/os/unix/ngx_process.c:198
on = 1
pid = 0
s = 2
#5 0x0000000000433576 in ngx_start_worker_processes
(cycle=0x801cf5050, n=8, type=-3) at
src/os/unix/ngx_process_cycle.c:362
i = 2
ch = {command = 1, pid = 78739, slot = 1, fd = 49}
---Type <return> to continue, or q <return> to quit---
#6 0x0000000000432d79 in ngx_master_process_cycle (cycle=0x801cf5050)
at src/os/unix/ngx_process_cycle.c:136
title = 0x803fb6fac "master process /usr/local/sbin/nginx"
p = (u_char *) 0x803fb6fd0 ""
size = 37
i = 1
n = 4
sigio = 2
set = {__bits = {0, 0, 0, 0}}
itv = {it_interval = {tv_sec = 0, tv_usec = 34367014912}, it_value =
{tv_sec = 1, tv_usec = 140737488346448}}
live = 34383286796
delay = 6
ls = (ngx_listening_t *) 0x801cf52b0
ccf = (ngx_core_conf_t *) 0x801cf5a50
#7 0x0000000000406ac3 in main (argc=1, argv=0x7fffffffdda8) at
src/core/nginx.c:412
i = 53
log = (ngx_log_t *) 0x6e27c0
cycle = (ngx_cycle_t *) 0x801cf5050
init_cycle = {conf_ctx = 0x0, pool = 0x801c07c00, log = 0x6e27c0,
new_log = {log_level = 0, file = 0x0, connection = 0, handler = 0,
data = 0x0, action = 0x0}, files = 0x0, free_connections = 0x0,
free_connection_n = 0, reusable_connections_queue = {prev = 0x0, next
= 0x0}, listening = {elts = 0x801c59600, nelts = 3, size = 216, nalloc
= 10, pool = 0x801c07c00}, paths = {elts = 0x0, nelts = 0,
size = 0, nalloc = 0, pool = 0x0}, open_files = {last = 0x0, part =
{elts = 0x0, nelts = 0, next = 0x0}, size = 0, nalloc = 0, pool =
0x0}, shared_memory = {last = 0x0, part = {elts = 0x0, nelts = 0,
next = 0x0}, size = 0, nalloc = 0, pool = 0x0}, connection_n = 0,
files_n = 0, connections = 0x0, read_events = 0x0, write_events = 0x0,
old_cycle = 0x0, conf_file = {len = 31,
data = 0x4b4ca0 "/usr/local/etc/nginx/nginx.conf"}, conf_param = {len
= 0, data = 0x0}, conf_prefix = {len = 21, data = 0x4b4ca0
"/usr/local/etc/nginx/nginx.conf"}, prefix = {len = 21,
data = 0x4b4c88 "/usr/local/etc/nginx/"}, lock_file = {len = 0, data =
0x0}, hostname = {len = 0, data = 0x0}}
ccf = (ngx_core_conf_t *) 0x801cf5a50
FreeBSD 9.1-RELEASE-p4 amd64
nginx 1.4.2
Как мне кажется, проблема появилась после включения websockets.
proxy_pass http://push;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
keepalive_timeout 1d;
proxy_read_timeout 1d;
На linux с epoll такая же проблема, (стектрейса пока нету, если надо
могу попытаться получить)
Подробная информация о списке рассылки nginx-ru