forked from tarantool/tarantool
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
app: start init script event loop explicitly
The motivation is to reduce time slip on Tarantool startup before running init scripts. Internal ev time is set in fiber_init/ev_default_loop and is not get updated until starting event loop. This causes timeouts slip up to 0.3 in debug ASAN build in init script (see tarantool#9261). Let's run event loop right at the beginning of the run_script_f before executing any script. This way besides updating internal ev time we make an explicit place of starting script event loop. Currently it is started lazily when config script yields. This will fix CI for PR tarantool/tarantool-ee#572 for debug ASAN workflow. We can also remove start_loop condition. It does not make sense now. It was added in the commit 3a85143 ("Fix tarantool -e "os.exit()" hang") but since then we start to stop event loop after handling os.exit(). Also this fixes tarantool#9266. The issue is we don't have an event loop to run on shutdown triggers if -e command line expression add such a trigger and then call os.exit(). Follow-up tarantool#7327 Closes tarantool#9266 NO_DOC=bugfix
- Loading branch information
Showing
3 changed files
with
49 additions
and
18 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
changelogs/unreleased/gh-9266-fix-on-shutdown-and-osexit-from-cmd-expr.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## bugfix/box | ||
|
||
* Fixed a bug when `on_shutdown` triggers weren't run if `os.exit()` was | ||
called from `-e` command-line option (gh-9266). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
test/box-luatest/gh_9266_fix_on_shutdown_and_osexit_from_cmd_expr_test.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
local t = require('luatest') | ||
local popen = require('popen') | ||
|
||
local g = t.group() | ||
|
||
local tarantool = arg[-1] | ||
|
||
g.after_each(function() | ||
if g.handle ~= nil then | ||
g.handle:close() | ||
end | ||
g.handle = nil | ||
end) | ||
|
||
g.test = function() | ||
local code = [[ | ||
box.ctl.on_shutdown(function() | ||
print('hello') | ||
end) | ||
os.exit() | ||
]] | ||
local handle, err = popen.new({tarantool, '-e', code}, | ||
{stdout = popen.opts.PIPE, | ||
stdin = popen.opts.DEVNULL, | ||
stderr = popen.opts.DEVNULL}) | ||
assert(handle, err) | ||
g.handle = handle | ||
local output, err = handle:read({timeout = 3}) | ||
assert(output, err) | ||
t.assert_equals(output, "hello\n") | ||
local status = handle:wait() | ||
t.assert_equals(status.state, 'exited') | ||
t.assert_equals(status.exit_code, 0) | ||
end |