Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: Serge Petrenko <sergepetrenko@tarantool.org>,
	Cyrill Gorcunov <gorcunov@gmail.com>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH 1/4] box: add a single execution guard to clear_synchro_queue
Date: Mon, 21 Dec 2020 18:11:58 +0100	[thread overview]
Message-ID: <fd8261df-0fd2-2553-1efd-206ee5596eef@tarantool.org> (raw)
In-Reply-To: <99e20e44-9833-5e32-00dc-d6ed91058960@tarantool.org>

>> But I don't mind having this guard here if you want it. Only my thoughts.
>>> if (try_wait) { /* Wait until pending confirmations/rollbacks reach us. */ diff --git a/src/box/lua/ctl.c b/src/box/lua/ctl.c index bf26465e6..a3447f3e7 100644 --- a/src/box/lua/ctl.c +++ b/src/box/lua/ctl.c @@ -81,8 +81,8 @@ lbox_ctl_on_schema_init(struct lua_State *L) static int lbox_ctl_clear_synchro_queue(struct lua_State *L) { - (void) L; - box_clear_synchro_queue(true); + if (box_clear_synchro_queue(true) != 0) + return luaT_error(L); 
>> Maybe better use nil + error object return way? I thought we still use it in the new code.
> 
> Hm, I haven't seen us do that in lua/C.
> As far as I know, every box.* method throws a lua error in case of failure.
> I may miss something. Is there a reason for returning nil + error instead of
> throwing?
The only reason is that it is our new rule for writing Lua code.
http://www.tarantool.io/en/doc/latest/dev_guide/lua_style_guide/#error-handling

Not every box function, really.

As some examples I can remember box.session.push(),
box.unprepare, box.execute, box.prepare.

There are also examples for non-box Lua methods. You
can grep by luaT_push_nil_and_error() to find almost all
usages in Lua C API. To find usages in .lua files you
can try to look for `return nil, err*`, but it won't
show everything.

For me nil,err looks better, but I understand that there
is a lot of old code still using exceptions. And maybe we
would better stick to them. I suggest to ask in the chat
if in doubt.

  reply	other threads:[~2020-12-21 17:12 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-10 20:55 [Tarantool-patches] [PATCH 0/4] make clear_synchro_queue commit everything Serge Petrenko
2020-12-10 20:55 ` [Tarantool-patches] [PATCH 1/4] box: add a single execution guard to clear_synchro_queue Serge Petrenko
2020-12-17 21:43   ` Vladislav Shpilevoy
2020-12-21 10:18     ` Serge Petrenko
2020-12-21 17:11       ` Vladislav Shpilevoy [this message]
2020-12-23 12:01         ` Serge Petrenko
2020-12-10 20:55 ` [Tarantool-patches] [PATCH 2/4] relay: rename is_raft_enabled message to relay_is_running Serge Petrenko
2020-12-17 21:43   ` Vladislav Shpilevoy
2020-12-23 12:01     ` Serge Petrenko
2020-12-10 20:55 ` [Tarantool-patches] [PATCH 3/4] relay: introduce relay_lsn_watcher Serge Petrenko
2020-12-17 21:43   ` Vladislav Shpilevoy
     [not found]     ` <4b7f4fc1-6d48-4332-c432-1eeb0b28c016@tarantool.org>
2020-12-23 12:03       ` Serge Petrenko
2020-12-10 20:55 ` [Tarantool-patches] [PATCH 4/4] box: rework clear_synchro_queue to commit everything Serge Petrenko
2020-12-17 21:43   ` Vladislav Shpilevoy
2020-12-23 12:04     ` Serge Petrenko
2020-12-11  7:15 ` [Tarantool-patches] [PATCH 0/4] make clear_synchro_queue " Serge Petrenko
2020-12-11  9:19 ` Serge Petrenko

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=fd8261df-0fd2-2553-1efd-206ee5596eef@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=gorcunov@gmail.com \
    --cc=sergepetrenko@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH 1/4] box: add a single execution guard to clear_synchro_queue' \
    /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