From: Serge Petrenko <sergepetrenko@tarantool.org> To: kostja@tarantool.org Cc: tarantool-patches@freelists.org, Serge Petrenko <sergepetrenko@tarantool.org> Subject: [tarantool-patches] [PATCH v3 0/3] box: implement on_shutdown triggers Date: Tue, 11 Dec 2018 16:24:37 +0300 [thread overview] Message-ID: <cover.1544533138.git.sergepetrenko@tarantool.org> (raw) 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)
next reply other threads:[~2018-12-11 13:26 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-12-11 13:24 Serge Petrenko [this message] 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
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=cover.1544533138.git.sergepetrenko@tarantool.org \ --to=sergepetrenko@tarantool.org \ --cc=kostja@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [tarantool-patches] [PATCH v3 0/3] box: implement 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