Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: Nikita Pettik <korablev@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH 1/2] errinj: introduce delayed injection
Date: Thu, 7 May 2020 23:47:36 +0200	[thread overview]
Message-ID: <5601c484-849d-5425-cdf9-bb5080160c03@tarantool.org> (raw)
In-Reply-To: <20200507135001.GC11724@tarantool.org>

Hi! Thanks for the fixes!

>>> diff --git a/src/errinj.h b/src/errinj.h
>>> index 2cb090b68..990f4921d 100644
>>> --- a/src/errinj.h
>>> +++ b/src/errinj.h
>>> @@ -149,6 +149,7 @@ errinj_foreach(errinj_cb cb, void *cb_ctx);
>>>  #ifdef NDEBUG
>>>  #  define ERROR_INJECT(ID, CODE)
>>>  #  define errinj(ID, TYPE) ((struct errinj *) NULL)
>>> +#  define ERROR_INJECT_DELAYED(ID, DELAY, CODE)
>>>  #else
>>>  #  /* Returns the error injection by id */
>>>  #  define errinj(ID, TYPE) \
>>> @@ -162,6 +163,14 @@ errinj_foreach(errinj_cb cb, void *cb_ctx);
>>>  		if (errinj(ID, ERRINJ_BOOL)->bparam) \
>>>  			CODE; \
>>>  	} while (0)
>>> +#  define ERROR_INJECT_DELAYED(ID, DELAY, CODE) \
>>> +	do { \
>>> +		static int _DELAY##ID = DELAY; \
>>> +		if (errinj(ID, ERRINJ_BOOL)->bparam) { \
>>> +			if (_DELAY##ID-- == 0) \
>>> +				CODE; \
>>> +		} \
>>> +	} while (0)
>>
>> The method is fine unless you will ever want to set the same
>> error injection twice without restarting Tarantool. With this
>> solution there is no way to reset _DELAY##ID back to the same or
>> a different value. It will stay 0 until restart. This a serious
>> enough problem to reconsider the approach. There are injections
>> used in multiple tests, and we can't count on restart after each
>> one.
> 
> Yep, this is obvious drawback of chosen implementation.
>  
>> This is the reason why you won't be able to use this delayed
>> injection for VY_STMT_ALLOC in 'uninitialized memory' patchset.
>>
>> 'Delayed' easily can be implemented by iparam. For example, look
>> at ERRINJ_WAL_FALLOCATE and your own VY_STMT_ALLOC. You set
>> iparam to some value, then you decrement it until 0, and inject
>> the error at this moment. Works perfectly fine, and without
>> introducing any new unrecoverable ERRINJ_ counters. However if you
>> want to simplify that, just wrap the iparam-method into a macros.
>> Even the same name could be fine - ERROR_INJECT_DELAYED.
> 
> Ok, here's diff:
> 
> diff --git a/src/errinj.h b/src/errinj.h
> index 990f4921d..945abb939 100644
> --- a/src/errinj.h
> +++ b/src/errinj.h
> @@ -163,12 +163,10 @@ errinj_foreach(errinj_cb cb, void *cb_ctx);
>                 if (errinj(ID, ERRINJ_BOOL)->bparam) \
>                         CODE; \
>         } while (0)
> -#  define ERROR_INJECT_DELAYED(ID, DELAY, CODE) \
> +#  define ERROR_INJECT_COUNTDOWN(ID, CODE) \
>         do { \
> -               static int _DELAY##ID = DELAY; \
> -               if (errinj(ID, ERRINJ_BOOL)->bparam) { \
> -                       if (_DELAY##ID-- == 0) \
> -                               CODE; \
> +               if (errinj(ID, ERRINJ_INT)->iparam-- == 0) { \
> +                       CODE; \
>                 } \
>         } while (0)
>  #endif

One last thing - could you please align '\' to the end of the lines?
By 80 symbols, using tabs. Recently we had a discussion with Cyrill G,
and he mentioned such not aligned things are hard to read. Physically.
Eyes literally are getting tired faster.

He also wants us to align struct members everywhere, but that is a
different topic to discuss.

  reply	other threads:[~2020-05-07 21:47 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-30 19:27 [Tarantool-patches] [PATCH 0/2] Fix crash in case of lack of FDs during recovery Nikita Pettik
2020-04-30 19:27 ` [Tarantool-patches] [PATCH 1/2] errinj: introduce delayed injection Nikita Pettik
2020-04-30 20:15   ` Konstantin Osipov
2020-04-30 20:55     ` Nikita Pettik
2020-05-01 19:15       ` Konstantin Osipov
2020-05-03 19:20   ` Vladislav Shpilevoy
2020-05-07 13:50     ` Nikita Pettik
2020-05-07 21:47       ` Vladislav Shpilevoy [this message]
2020-05-07 22:41         ` Nikita Pettik
2020-04-30 19:27 ` [Tarantool-patches] [PATCH 2/2] vinyl: drop wasted runs in case range recovery fails Nikita Pettik
2020-05-03 19:21   ` Vladislav Shpilevoy
2020-05-07 13:02     ` Nikita Pettik
2020-05-07 14:16       ` Konstantin Osipov
2020-05-07 21:47         ` Vladislav Shpilevoy
2020-05-07 22:37           ` Nikita Pettik
2020-05-07 21:47       ` Vladislav Shpilevoy
2020-05-07 22:36         ` Nikita Pettik
2020-05-10 19:59           ` Vladislav Shpilevoy
2020-05-12  1:16             ` Nikita Pettik
2020-05-03 19:20 ` [Tarantool-patches] [PATCH 0/2] Fix crash in case of lack of FDs during recovery Vladislav Shpilevoy
2020-05-07 14:11   ` Nikita Pettik
2020-05-12 20:53 ` Vladislav Shpilevoy
2020-05-12 20:56   ` Vladislav Shpilevoy
2020-05-12 22:45     ` Nikita Pettik
2020-05-13 20:19       ` 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=5601c484-849d-5425-cdf9-bb5080160c03@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH 1/2] errinj: introduce delayed injection' \
    /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