Tarantool development patches archive
 help / color / mirror / Atom feed
* [PATCH v4 0/2] box: implement on_shutdown triggers
@ 2018-12-29 13:45 Serge Petrenko
  2018-12-29 13:45 ` [PATCH v4 1/2] box: get rid of atexit() for calling cleanup routines Serge Petrenko
  2018-12-29 13:45 ` [PATCH v4 2/2] box: implement on_shutdown triggers Serge Petrenko
  0 siblings, 2 replies; 5+ messages in thread
From: Serge Petrenko @ 2018-12-29 13:45 UTC (permalink / raw)
  To: vdavydov.dev; +Cc: kostja, 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.

Changes in v4: 
  - squashed 2nd and 3rd patches
  - review fixes as per review by @locker
  - made 1st and 2nd patches independent.
    1st patch may be dropped if we decide not to
    implement it. 

The 1st patch moves tarantool_free() from atexit() to end of main().
As mentioned above, the only things still done in atexit() are stopping WAL 
thread and restoring terminal state.

Second patch implements on_shutdown triggers. The triggers are run from a fiber
before ev_loop break, and the last executed trigger breaks ev loop.
The triggers are exposed to lua via box.ctl.on_shutdown()

Serge Petrenko (2):
  box: get rid of atexit() for calling cleanup routines
  box: implement on_shutdown triggers

 src/box/box.cc         | 10 +++++
 src/box/box.h          | 10 +++++
 src/box/lua/ctl.c      |  8 ++++
 src/lua/trigger.c      |  5 ++-
 src/main.cc            | 83 +++++++++++++++++++++++++++++++++++-------
 test/box/misc.result   | 72 ++++++++++++++++++++++++++++++++++++
 test/box/misc.test.lua | 32 ++++++++++++++++
 7 files changed, 205 insertions(+), 15 deletions(-)

-- 
2.17.2 (Apple Git-113)

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

end of thread, other threads:[~2019-01-09 14:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-29 13:45 [PATCH v4 0/2] box: implement on_shutdown triggers Serge Petrenko
2018-12-29 13:45 ` [PATCH v4 1/2] box: get rid of atexit() for calling cleanup routines Serge Petrenko
2018-12-29 13:45 ` [PATCH v4 2/2] box: implement on_shutdown triggers Serge Petrenko
2019-01-09 10:14   ` Vladimir Davydov
2019-01-09 14:01     ` [tarantool-patches] " Konstantin Osipov

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