Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: tarantool-patches@dev.tarantool.org, gorcunov@gmail.com,
	sergepetrenko@tarantool.org
Subject: [Tarantool-patches] [PATCH 2/2] lua: separate sched and script diag
Date: Thu, 18 Mar 2021 01:02:04 +0100	[thread overview]
Message-ID: <d58c79b022238ad1e9fb9f10f52c3ca6ea55f6e1.1616025567.git.v.shpilevoy@tarantool.org> (raw)
In-Reply-To: <cover.1616025567.git.v.shpilevoy@tarantool.org>

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 #5906
---
 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
index 000000000..19ad44ca2
--- /dev/null
+++ b/changelogs/unreleased/swim-broadcast-error.md
@@ -0,0 +1,6 @@
+## 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).
diff --git a/src/lua/init.c b/src/lua/init.c
index 4729ad7a2..767abdfc5 100644
--- a/src/lua/init.c
+++ b/src/lua/init.c
@@ -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
-- 
2.24.3 (Apple Git-128)


  parent reply	other threads:[~2021-03-18  0:03 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-18  0:02 [Tarantool-patches] [PATCH 0/2] Swim broadcast errors Vladislav Shpilevoy via Tarantool-patches
2021-03-18  0:02 ` [Tarantool-patches] [PATCH 1/2] swim: add SO_BROADCAST option Vladislav Shpilevoy via Tarantool-patches
2021-03-18  0:49   ` Vladislav Shpilevoy via Tarantool-patches
2021-03-18 19:37   ` Cyrill Gorcunov via Tarantool-patches
2021-03-18 20:47     ` Vladislav Shpilevoy via Tarantool-patches
2021-03-18 21:27       ` Cyrill Gorcunov via Tarantool-patches
2021-03-18 22:34         ` Vladislav Shpilevoy via Tarantool-patches
2021-03-18 23:18         ` Vladislav Shpilevoy via Tarantool-patches
2021-03-19  6:53           ` Cyrill Gorcunov via Tarantool-patches
2021-03-19 20:18             ` Vladislav Shpilevoy via Tarantool-patches
2021-03-19 20:29               ` Cyrill Gorcunov via Tarantool-patches
2021-03-19 21:46             ` Vladislav Shpilevoy via Tarantool-patches
2021-03-19 22:15               ` Cyrill Gorcunov via Tarantool-patches
2021-03-18  0:02 ` Vladislav Shpilevoy via Tarantool-patches [this message]
2021-03-19 13:17 ` [Tarantool-patches] [PATCH 0/2] Swim broadcast errors Serge Petrenko via Tarantool-patches
2021-03-19 22:37 ` Vladislav Shpilevoy via Tarantool-patches

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=d58c79b022238ad1e9fb9f10f52c3ca6ea55f6e1.1616025567.git.v.shpilevoy@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=gorcunov@gmail.com \
    --cc=sergepetrenko@tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH 2/2] lua: separate sched and script diag' \
    /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