Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@freelists.org,
	Alexander Turenko <alexander.turenko@tarantool.org>,
	Kirill Shcherbatov <kshcherbatov@tarantool.org>
Cc: kostja@tarantool.org
Subject: [tarantool-patches] Re: [PATCH v1 1/3] box: rfc for stacked diagnostic area in Tarantool
Date: Thu, 8 Aug 2019 22:46:29 +0200	[thread overview]
Message-ID: <b9df6125-7e35-c8c3-f29a-fde0b1f3ae32@tarantool.org> (raw)
In-Reply-To: <20190807232755.s7gruhxeja75hob7@tkn_work_nb>

> I had the objection against a list of errors in the diagnostic area: a
> user may want to save an error, perform some new commands, which can
> rewrite a last diagnostic (replace the diagnostic list) and then (s)he
> may want to look at the stack of reasons of the saved error. But now it
> seems you discarded the idea. (BTW, it would be good to briefly mention
> changes you made for a new revision of your document: the text looks
> similar and it is hard to find differences.)

Not sure if I understood the problem. What is wrong the list of errors?
And how does it correlate with an error accidental removal? If I got
the problem right, it exists even now, and does not depend on structure
of an error. Even errno has that problem, and the only way to solve it -
save the error to a local variable, perform needed preparations, and look
at the saved value. You can do it now. Just save 'box.error.last()', do
your stuff, and deal with the saved value.

> 
> I think that struct error should have a pointer to its cause, which is
> another error.

But it does exactly this now. It is called 'reason', which IMO is
easier to understand. My first association with 'cause' is an informal
writing of 'because', and it confuses a bit.

> I like Java terminology here: cause is exactly what we want to save for
> an error. Wrap / unwrap (Go terminology) look too abstract and maybe
> even unclear for me. Maybe this terms appears from merry / xerror
> packages, which were inspired to wrap built-in errors with additional
> information (say, stack traces). It is up to maintainers, but my vote is
> for 'cause' field, 'get_cause()' and 'set_cause()' functions (maybe with
> some prefix, because it is C).

Strangely, but I understood wrap/unwrap easily. So I vote to keep them.
But if there are more people who doesn't understand, then here is my
humble proposal:

    C API:
    box_error_reason(const struct error *) // To get a reason error.
    box_error_set_reason(struct error *, struct error *) // To set a reason.

    Lua API:
    error:reason() -- Get a reason error.
    error:set_reason(reason) -- Set a reason error.

> 'Is' method (Go terminology, here it is named 'has') also don't look
> self-descriptive enough for me. I would name it 'find_cause()'.

I vote for just 'find'. I don't think 'cause' or 'reason' should be a
part of that function's name, because a real reason of the final result
is only one - the first error. This function on the contrary is able
to find any error in stack.

> 
> I doubt a bit that iproto change you proposed would be
> backward-compatible: imagine that you connect from an old tarantool to a
> new tarantool using net.box or handle errors using another existing
> connector. I would send those messages as before, but add a field with
> IPROTO_ERROR_LIST key in addition to existing IPROTO_ERROR (0x31) to a
> body map. The value can be a list of maps like {code = <mp_uint>,
> message = <mp_str>} or a list of list [<code>, <message>]. The
> IPROTO_ERROR_LIST should start from a last (top) error I think.

I agree. I forgot about backward compatibility. Indeed, we can send both
new single error, and a list of errors. The list can even contain the
last error second time, because anyway error packets are rare and not
normal. We may not optimize them too much in terms of space.

> 
> Maybe we should use 'warnings' term here if this feature is intended to
> be used for SQL warnings. If we want to use the proposed mechanics for
> warnings, then my proposal re using 'cause' term looks doubtful. Don't
> sure whether we should introduce some kind of warnings list for the
> diagnostic area or reuse 'cause' / 'parent' / ... field of struct error.
> 
> I didn't look at your patch: I want to agree on terms and overall
> approach first. At least one of maintainers should approve it.

Most of you objections are about names, so I guess you already can take
a look at the functionality and tests.

  reply	other threads:[~2019-08-08 20:44 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-01 11:13 [tarantool-patches] [PATCH v1 0/3] box: stacked diagnostics area in fiber Kirill Shcherbatov
2019-08-01 11:13 ` [tarantool-patches] [PATCH v1 1/3] box: rfc for stacked diagnostic area in Tarantool Kirill Shcherbatov
2019-08-05 21:16   ` [tarantool-patches] " Vladislav Shpilevoy
     [not found]     ` <06bd2140-3d2b-4bc3-7bc4-5f3d293bf891@tarantool.org>
2019-08-06 20:50       ` Vladislav Shpilevoy
2019-08-07 23:27   ` Alexander Turenko
2019-08-08 20:46     ` Vladislav Shpilevoy [this message]
2019-08-08 23:29       ` Alexander Turenko
2019-08-09 19:25         ` Vladislav Shpilevoy
2019-08-12 20:35         ` Konstantin Osipov
2019-08-01 11:13 ` [tarantool-patches] [PATCH v1 2/3] box: stacked diagnostics area in fiber Kirill Shcherbatov
2019-08-05 21:16   ` [tarantool-patches] " Vladislav Shpilevoy
2019-08-01 11:13 ` [tarantool-patches] [PATCH v1 3/3] box: extend ffi error object API Kirill Shcherbatov
2019-08-05 21:18   ` [tarantool-patches] " Vladislav Shpilevoy
2019-08-06  7:56     ` Kirill Shcherbatov
2019-08-06 20:50       ` Vladislav Shpilevoy
2019-08-08 23:33     ` Alexander Turenko
2019-08-09 19:27       ` Vladislav Shpilevoy

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=b9df6125-7e35-c8c3-f29a-fde0b1f3ae32@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=alexander.turenko@tarantool.org \
    --cc=kostja@tarantool.org \
    --cc=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH v1 1/3] box: rfc for stacked diagnostic area in Tarantool' \
    /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