[Tarantool-patches] [PATCH 2/2] lua: separate sched and script diag
v.shpilevoy at tarantool.org
Thu Mar 18 03:02:04 MSK 2021
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
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.
changelogs/unreleased/swim-broadcast-error.md | 6 ++++++
src/lua/init.c | 12 +++++++++++-
2 files changed, 17 insertions(+), 1 deletion(-)
create mode 100644 changelogs/unreleased/swim-broadcast-error.md
diff --git a/changelogs/unreleased/swim-broadcast-error.md b/changelogs/unreleased/swim-broadcast-error.md
new file mode 100644
@@ -0,0 +1,6 @@
+* 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).
diff --git a/src/lua/init.c b/src/lua/init.c
index 4729ad7a2..767abdfc5 100644
@@ -718,8 +718,16 @@ tarantool_lua_run_script(char *path, bool interactive,
if (script_fiber == NULL)
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;
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,
/* The fiber running the startup script has ended. */
script_fiber = NULL;
+ diag_move(&script_diag, diag_get());
* Result can't be obtained via fiber_join - script fiber
* never dies if os.exit() was called. This is why diag
2.24.3 (Apple Git-128)
More information about the Tarantool-patches