Tarantool development patches archive
 help / color / mirror / Atom feed
From: Konstantin Osipov <kostja@tarantool.org>
To: tarantool-patches@freelists.org
Subject: [tarantool-patches] [kostja@tarantool.org: Re: [PATCH v2 3/3] box: pass signal to on_shutdown triggers]
Date: Thu, 6 Dec 2018 11:51:56 +0300	[thread overview]
Message-ID: <20181206085156.GA7100@chai> (raw)

----- Forwarded message from Konstantin Osipov <kostja@tarantool.org> -----

Date: Wed, 5 Dec 2018 00:55:47 +0300
From: Konstantin Osipov <kostja@tarantool.org>
To: tarantool-patches@freelists.org
Cc: Serge Petrenko <sergepetrenko@tarantool.org>
Subject: Re: [tarantool-patches] [PATCH v2 3/3] box: pass signal to on_shutdown
	triggers

* Serge Petrenko <sergepetrenko@tarantool.org> [18/11/26 17:26]:

> Start passing signal which caused termination to on_shutdown triggers.
> 
> Closes #1607
> 
> @TarantoolBot document
> Title: Document box.ctl.on_shutdown triggers
> on_shutdown triggers may be set similar to space:on_replace triggers:
> ```
> box.ctl.on_shutdown(new_trigger, old_trigger)
> ```
> The triggers will be run when tarantool exits either normally, or due to
> receiving a signal `SIGTERM`, `SIGINT`, `SIGHUP`.
> The signal which caused termination (if any) is available to the trigger
> as 1st parameter.

Unfortunately this doesn't capture fatal signals- SIGSEGV and
SIGABORT. Not to mention that the triggers are not invoked on
these signals. Without these signals passing the signal number is
not of much use. Let's drop this altogether. And not forget to
document cases when on-shutdown triggers are *not* invoked in the
docbot request.

As to limitations, it's quite OK you can't call 'box' methods on
shutdown, but I believe the user expected to be able to yield on
shutdown, i.e. use the app server.
Can we change the timing of trigger invocation to "before ev loop
break" ? 

I've been wanting to stop using exit() and atexit handlers for
shutdown for a long time for two reasons:

- their behaviour in a multi-threaded program is not defined and
  not documented. When atexit() is invoked replication and other
  threads still run on Linux, but I wasn't able to find any
  confirmation in POSIX that this is standard. POSIX says that
  threads cease to exist on return from main(), but doesn't make
  it clear exactly when :). 
- reasoning about the way atexit() handlers work with the event
  loop is very hard as well

I'd like to propose a solution for this issue.
We could fiber_call() a fiber which would in turn call
ev_loop_break(). This would make the shutdown cleanups very simple
and straightforward, as well as allow using yields in shutdown
triggers.  

Could you please prepare a patch for it? We could perhaps even
reuse sched fiber for this purpose, after a few tweaks, so that we
don't have to reserve an extra fiber stack for the purpose.

-- 
Konstantin Osipov, Moscow, Russia, +7 903 626 22 32
http://tarantool.io - www.twitter.com/kostja_osipov

----- End forwarded message -----

-- 
Konstantin Osipov, Moscow, Russia, +7 903 626 22 32
http://tarantool.io - www.twitter.com/kostja_osipov

                 reply	other threads:[~2018-12-06  8:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181206085156.GA7100@chai \
    --to=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] [kostja@tarantool.org: Re: [PATCH v2 3/3] box: pass signal to on_shutdown triggers]' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox