Keepalived Connections Reset after reloading the configuration (HUP Signal)

Maxim Dounin mdounin at mdounin.ru
Mon Oct 12 20:14:37 UTC 2020


Hello!

On Thu, Oct 08, 2020 at 03:31:57AM -0400, tored wrote:

> Thanks Maxim to taking the time to respond.
> 
> > This feature wasn't removed in 5e6142609e48, but rather it was 
> > changed how things work: instead of doing a full scan over all 
> > connections on each event loop iteration, nginx now does it only 
> > once, and also makes sure no new idle connections are added after 
> > the shutdown signal.
> > 
> 
> I don't fully understand what happens to non-idle keep-alive connections
> after the shutdown signal is sent.
> 
> If I understand correctly, non-idle keep-alive connections will continue to
> serve requests after a graceful shutdown, until they are terminated by
> "normal" events, such as:
> * connection is closed/terminated by the client
> * or by the server, e.g if (r->connection->requests >=
> clcf->keepalive_requests)
> * or if keepalive_timeout is meet
> * any other event that would close the connection during normal operation

No.  Connections won't be allowed to go into the keepalive state 
after a graceful shutdown was initiated, see the following check 
in the ngx_http_finalize_connection() function:

    if (!ngx_terminate
         && !ngx_exiting
         && r->keepalive
         && clcf->keepalive_timeout > 0)
    {
        ngx_http_set_keepalive(r);
        return;
    }

That is, additional requests will be only processed on a 
connection if keepalive is enabled and nginx worker is not 
shutting down.  If nginx worker is shutting down, the connection 
will be closed.

-- 
Maxim Dounin
http://mdounin.ru/


More information about the nginx mailing list