comparison src/http/ngx_http_upstream.c @ 9202:e88cdaa0f1ff

AIO operations now add timers (ticket #2162). Each AIO (thread IO) operation being run is now accompanied with 1-minute timer. This timer prevents unexpected shutdown of the worker process while an AIO operation is running, and logs an alert if the operation is running for too long. This fixes "open socket left" alerts during worker processes shutdown due to pending AIO (or thread IO) operations while corresponding requests have no timers. In particular, such errors were observed while reading cache headers (ticket #2162), and with worker_shutdown_timeout.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 29 Jan 2024 10:31:37 +0300
parents 8d0753760546
children 0de20f43db25
comparison
equal deleted inserted replaced
9201:791ead216b03 9202:e88cdaa0f1ff
3947 3947
3948 r->main->blocked++; 3948 r->main->blocked++;
3949 r->aio = 1; 3949 r->aio = 1;
3950 p->aio = 1; 3950 p->aio = 1;
3951 3951
3952 ngx_add_timer(&task->event, 60000);
3953
3952 return NGX_OK; 3954 return NGX_OK;
3953 } 3955 }
3954 3956
3955 3957
3956 static void 3958 static void
3964 3966
3965 ngx_http_set_log_request(c->log, r); 3967 ngx_http_set_log_request(c->log, r);
3966 3968
3967 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, 3969 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
3968 "http upstream thread: \"%V?%V\"", &r->uri, &r->args); 3970 "http upstream thread: \"%V?%V\"", &r->uri, &r->args);
3971
3972 if (ev->timedout) {
3973 ngx_log_error(NGX_LOG_ALERT, c->log, 0,
3974 "thread operation took too long");
3975 ev->timedout = 0;
3976 return;
3977 }
3978
3979 if (ev->timer_set) {
3980 ngx_del_timer(ev);
3981 }
3969 3982
3970 r->main->blocked--; 3983 r->main->blocked--;
3971 r->aio = 0; 3984 r->aio = 0;
3972 3985
3973 #if (NGX_HTTP_V2) 3986 #if (NGX_HTTP_V2)