Skip to content
Snippets Groups Projects
Commit f4e248c0 authored by Vladislav Shpilevoy's avatar Vladislav Shpilevoy
Browse files

lua: separate sched and script diag

When Lua main script was launched, the sched fiber passed its own
diag to the script's fiber. When the script was finished, it put
its error into the diag. The sched fiber then checked if the diag
is empty to detect an error.

But it wasn't really correct. The error could also happen right in
the scheduler fiber in a libev callback. For example, in one of
ev_io callbacks in SWIM. Then the process would end with an error
even if the script was finished successfully.

These errors were not related to the main fiber executing the
script.

The patch makes so the scheduler fiber's diag no longer is used as
an indication of an error in the script. Instead, a new diag is
created on the stack of the scheduler's fiber, where the Lua
script saves the error.

Closes #5864
parent 1844eb6f
No related branches found
No related tags found
No related merge requests found
## bugfix/swim
* Fix `<swim_instance>:broadcast()` which does not work on non-local addresses
and spams "Permission denied" errors to the log. Also after instance
termination it could return a non-0 exit code even if there was no errors in
the script, and spam the error again (gh-5864).
......@@ -718,8 +718,16 @@ tarantool_lua_run_script(char *path, bool interactive,
if (script_fiber == NULL)
panic("%s", diag_last_error(diag_get())->errmsg);
script_fiber->storage.lua.stack = tarantool_L;
/*
* Create a new diag on the stack. Don't pass fiber's diag, because it
* might be overwritten by libev callbacks invoked in the scheduler
* fiber (which is this), and therefore can't be used as a sign of fail
* in the script itself.
*/
struct diag script_diag;
diag_create(&script_diag);
fiber_start(script_fiber, tarantool_L, path, interactive,
optc, optv, argc, argv, diag_get());
optc, optv, argc, argv, &script_diag);
/*
* Run an auxiliary event loop to re-schedule run_script fiber.
......@@ -729,6 +737,8 @@ tarantool_lua_run_script(char *path, bool interactive,
ev_run(loop(), 0);
/* The fiber running the startup script has ended. */
script_fiber = NULL;
diag_move(&script_diag, diag_get());
diag_destroy(&script_diag);
/*
* Result can't be obtained via fiber_join - script fiber
* never dies if os.exit() was called. This is why diag
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment