Tarantool development patches archive
 help / color / mirror / Atom feed
From: Serge Petrenko <sergepetrenko@tarantool.org>
To: Vladimir Davydov <vdavydov.dev@gmail.com>
Cc: tarantool-patches@freelists.org, Kirill Yukhin <kyukhin@tarantool.org>
Subject: Re: [tarantool-patches] Re: [PATCH v2] xrow: print corrupted rows on decoding error.
Date: Thu, 4 Apr 2019 14:52:25 +0300	[thread overview]
Message-ID: <338F2586-287A-4521-A6EE-F9E738FF6701@tarantool.org> (raw)
In-Reply-To: <20190403091827.qh5rxxpsbrkl35bp@esperanza>


Hi!

> 3 апр. 2019 г., в 12:18, Vladimir Davydov <vdavydov.dev@gmail.com> написал(а):
> 
> On Mon, Apr 01, 2019 at 04:09:06PM +0300, Serge Petrenko wrote:
>> Add row hex printing to log on verbose level. This would be useful
>> during investigation of errors related to invalid msgpack packet
>> arrival.
>> 
>> Here's some example output:
>> ```
>> 2019-04-01 16:04:51.629 [31304] iproto V> Corrupted row is: 3D A5 41 55 99 18 A8 08 C2 40 2B BA 50 12 F6 C6 0B 27 66 1C
>> 2019-04-01 16:04:51.629 [31304] iproto xrow.c:133 E> ER_INVALID_MSGPACK: Invalid MsgPack - packet header
>> ```
>> 
>> Related to #4040
>> ---
>> https://github.com/tarantool/tarantool/tree/sp/xrow-decode-verbose-err
>> https://github.com/tarantool/tarantool/issues/4040
>> 
>> Changes in v2:
>>  - make xrow_on_decode_err a macro instead of a
>>    function to preserve line where error occurs.
>>  - add a test case.
>>  - always allocate buffer for hex dump with malloc
>>  - add logging on all errors related to invalid
>>    msgpack and missing request field.
>> 
>> src/box/xrow.c            | 116 ++++++++++++++++++++++++++------------
>> test/box/net.box.result   |  34 +++++++++++
>> test/box/net.box.test.lua |  16 ++++++
>> 3 files changed, 131 insertions(+), 35 deletions(-)
>> 
>> diff --git a/src/box/xrow.c b/src/box/xrow.c
>> index 73d9e739b..fdd15bef3 100644
>> --- a/src/box/xrow.c
>> +++ b/src/box/xrow.c
>> @@ -88,15 +88,49 @@ mp_decode_vclock(const char **data, struct vclock *vclock)
>> 	return 0;
>> }
>> 
>> +/**
>> + * Set diagnostics with an error and log the corrupted row
>> + * which caused the error.
>> + * Optionally, if log_level is 'verbose' or greater,
>> + * dump the corrupted row contents in hex to the log.
>> + *
>> + * @param what - exception to set.
>> + * @param desc_str - error description string.
>> + */
>> +#define xrow_on_decode_err(_start, _end, _what, _desc_str) do {				\
>> +	diag_set(ClientError, _what, _desc_str);					\
>> +											\
>> +	if (!say_log_level_is_enabled(S_VERBOSE))					\
>> +		break;									\
>> +											\
>> +	size_t _len = 3 * ((const char *)(_end) - (const char *)(_start) + 1);		\
> 
> Nit: shouldn't +1 be outside the parentheses?

Yes, I guess I meant the interval to be inclusive.
But since it is not, the ‘+1’ should be outside.

> 
>> +	char *_buf = (char *)malloc(_len);						\
> 
> Nit: we don't usually prefix names with underscores, because this may
> conflict with libc internal macro definitions.

Ok. Do you want me to fix it?

> 
> Other than that this patch looks good to me. Do we need it in 1.10?

Yes, we need it in 1.10.

  parent reply	other threads:[~2019-04-04 11:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-01 13:09 Serge Petrenko
2019-04-03  9:18 ` Vladimir Davydov
2019-04-03  9:41   ` [tarantool-patches] " Kirill Yukhin
2019-04-04 11:52   ` Serge Petrenko [this message]
2019-04-04 12:06     ` Vladimir Davydov
2019-04-04 12:29       ` Serge Petrenko
2019-04-04 14:51         ` Vladimir Davydov
2019-04-05  6:18           ` Konstantin Osipov
2019-04-05  8:06             ` Vladimir Davydov
2019-04-05 13:20               ` Konstantin Osipov
2019-04-05 13:43                 ` Vladimir Davydov

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=338F2586-287A-4521-A6EE-F9E738FF6701@tarantool.org \
    --to=sergepetrenko@tarantool.org \
    --cc=kyukhin@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=vdavydov.dev@gmail.com \
    --subject='Re: [tarantool-patches] Re: [PATCH v2] xrow: print corrupted rows on decoding error.' \
    /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