Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCH v3 0/3] box: implement on_shutdown triggers
@ 2018-12-11 13:24 Serge Petrenko
  2018-12-11 13:24 ` [tarantool-patches] [PATCH v3 1/3] box: get rid of atexit() for calling cleanup routine Serge Petrenko
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Serge Petrenko @ 2018-12-11 13:24 UTC (permalink / raw)
  To: kostja; +Cc: tarantool-patches, Serge Petrenko

This patchset adds on_shutdown triggers which can be registered from lua 
via box.ctl.on_shutdown() and are run on tarantool shutdown.

Issue: https://github.com/tarantool/tarantool/issues/1607
Branch: https://github.com/tarantool/tarantool/tree/sp/gh-1607-on-exit-triggers

Changes in v2: 
  - added 3rd patch which passes signals to triggers.
  - run on_shutdown triggers even if box is not configured.
  - add a documentation request to the 3rd patch.

Changes in v3: 
  - remove the patch which passes signals to the trigger, since
    the triggers are not run on fatal signals at all, and doing
    this for SIGTERM or SIGINT is not of much use.
  - Add a new patch which moves tarantool_free() from atexit()
    to end of main(). Only close the journal and restore terminal state
    (if needed) in atexit handlers. Also in signal handler create
    a new fiber which breaks the event loop. on_shutdown triggers will
    be run from this fiber before ev loop break.
  - add tests that on_shutdown triggers can yield to the third patch.

AFAICS now there are no limitations on what can be done in on_shutdown
triggers: you may sleep, yield, perform DML/DDL requests.

First patch moves tarantool_free() from atexit() to end of main(),
alters signal handler for SIGINT, SIGHUP, SIGTERM to create a new fiber
which can be used to do some work on shutdown (run on_shutdown triggers)
and then break the event loop.
As mentioned above, the only things still done in atexit() are stopping
WAL thread and 

Second patch was originally made by Kostja and implemented on_shutdown
triggers. I altered it a bit so that on_shutdown triggers are run from
a fiber before event loop break, this allows us to yield in on_shutdown
triggers and to use box library.

Third patch expands box.ctl interface by introducing box.ctl.on_shutdown()
function to register on_shutdown triggers from lua.

Konstantin Osipov (1):
  box: implement on_shutdown triggers

Serge Petrenko (2):
  box: get rid of atexit() for calling cleanup routine
  box: introduce on_shutdown triggers to lua

 src/box/box.cc         | 16 +++++++++
 src/box/box.h          | 18 ++++++++++
 src/box/lua/ctl.c      | 21 ++++++++++++
 src/main.cc            | 75 ++++++++++++++++++++++++++++++++++--------
 test/box/misc.result   | 48 +++++++++++++++++++++++++++
 test/box/misc.test.lua | 19 +++++++++++
 6 files changed, 183 insertions(+), 14 deletions(-)

-- 
2.17.2 (Apple Git-113)

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2018-12-29 13:54 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-11 13:24 [tarantool-patches] [PATCH v3 0/3] box: implement on_shutdown triggers Serge Petrenko
2018-12-11 13:24 ` [tarantool-patches] [PATCH v3 1/3] box: get rid of atexit() for calling cleanup routine Serge Petrenko
2018-12-27 12:43   ` Vladimir Davydov
2018-12-27 12:50     ` Konstantin Osipov
2018-12-27 12:56       ` Vladimir Davydov
2018-12-28  7:43         ` [tarantool-patches] " Konstantin Osipov
2018-12-28  7:58           ` Vladimir Davydov
2018-12-29 13:54             ` Serge Petrenko
2018-12-11 13:24 ` [tarantool-patches] [PATCH v3 2/3] box: implement on_shutdown triggers Serge Petrenko
2018-12-27 13:11   ` Vladimir Davydov
2018-12-11 13:24 ` [tarantool-patches] [PATCH v3 3/3] box: introduce on_shutdown triggers to lua Serge Petrenko
2018-12-27 13:14   ` Vladimir Davydov

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