From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 0971030DE1 for ; Thu, 6 Dec 2018 03:51:59 -0500 (EST) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id stXpHgCfzu6C for ; Thu, 6 Dec 2018 03:51:58 -0500 (EST) Received: from smtp39.i.mail.ru (smtp39.i.mail.ru [94.100.177.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id C038C30DDB for ; Thu, 6 Dec 2018 03:51:58 -0500 (EST) Received: by smtp39.i.mail.ru with esmtpa (envelope-from ) id 1gUpO0-0001xG-Ou for tarantool-patches@freelists.org; Thu, 06 Dec 2018 11:51:57 +0300 Date: Thu, 6 Dec 2018 11:51:56 +0300 From: Konstantin Osipov Subject: [tarantool-patches] [kostja@tarantool.org: Re: [PATCH v2 3/3] box: pass signal to on_shutdown triggers] Message-ID: <20181206085156.GA7100@chai> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org ----- Forwarded message from Konstantin Osipov ----- Date: Wed, 5 Dec 2018 00:55:47 +0300 From: Konstantin Osipov To: tarantool-patches@freelists.org Cc: Serge Petrenko Subject: Re: [tarantool-patches] [PATCH v2 3/3] box: pass signal to on_shutdown triggers * Serge Petrenko [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