Welcome! Log In Create A New Profile

Advanced

Re: Re: patch: call modules' exit_process in reverse order

April 29, 2022 01:26AM
helloļ¼ŒDounin,

I also had read many discussions , confusing how to properly maintain the
dependency orders. So despite the usage of thread pool module, I think it's
a principal to call the plugin's construction , then call their destruction
functions in reverse order, when we design some kind of dynamic plugin
mechanism.

Does that make sense?


Or nginx has some consideration to force destruction follow same execution
order with construction?


Thanks & Regards

On Thu, 28 Apr 2022, 07:55 Maxim Dounin, <mdounin@mdounin.ru> wrote:

> Hello!
>
> On Sun, Apr 24, 2022 at 04:33:04PM +0800, shanlei@asiainfo.com wrote:
>
> > # HG changeset patch
> > # User stdanley <shanlei@asiainfo.com>
> > # Date 1650788278 -28800
> > # Sun Apr 24 16:17:58 2022 +0800
> > # Node ID 522acbe88486d027383075c8208edd6fcc0a3aa6
> > # Parent a736a7a613ea6e182ff86fbadcb98bb0f8891c0b
> > patch: call modules' exit_process in reverse order to solve module
> > dependency.
> > We once have developed a module which depends on ngx_thread_pool module..
> > but nginx hungs when began to shutdown. trace shows that ngx_thread_pool
> > cant finish "exit_process" because our module is using a thread, our
> > module must
> > call "exit_process" before ngx_thread_pool.
> > so we present this patch to solve modules' dependency issue.
>
> Thank you for the patch.
>
> First of all, you may want to consider this section in the
> development guide:
>
> http://nginx.org/en/docs/dev/development_guide.html#threads_pitfalls
>
> Using threads in nginx is usually a bad idea. Thread pools, in
> particular, are designed to be used to offload short operations like
> read() syscalls. And these operations are expected to be finished
> before nginx exit, so thread pool's exit handler waits for all
> threads to complete.
>
> If you are sure you have to use threads, and thread pools in
> particular, and with some long-running tasks, you may want to
> consider other ways to signal your threads to exit. In
> particular, checking ngx_exiting/ngx_quit/ngx_terminate
> periodically might be a way to go. Though I would recommend to
> reconsider using long-running thread tasks anyway.
>
> As for the patch, it looks wrong to me. While changing the
> exit_process() callback order might solve your particular
> dependency issue, similar issues might easily appear with any
> order.
>
> Hope this helps.
>
> --
> Maxim Dounin
> http://mdounin.ru/
> _______________________________________________
> nginx-devel mailing list -- nginx-devel@nginx.org
> To unsubscribe send an email to nginx-devel-leave@nginx.org
>
_______________________________________________
nginx-devel mailing list -- nginx-devel@nginx.org
To unsubscribe send an email to nginx-devel-leave@nginx.org
Subject Author Views Posted

patch: call modules' exit_process in reverse order

shanlei 612 April 24, 2022 04:36AM

Re: patch: call modules' exit_process in reverse order

Maxim Dounin 169 April 27, 2022 07:58PM

Re: Re: patch: call modules' exit_process in reverse order

shanlei 193 April 29, 2022 01:26AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 174
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready