Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: Nikita Pettik <korablev@tarantool.org>,
	tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH 1/2] errinj: introduce delayed injection
Date: Sun, 3 May 2020 21:20:53 +0200	[thread overview]
Message-ID: <cd76df9e-bd25-757b-b1f4-019028024dee@tarantool.org> (raw)
In-Reply-To: <1fb821b72a258f638109ea5e2e9a6bfd6106b9da.1588273848.git.korablev@tarantool.org>

Thanks for the patch!

> 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.

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.

Moreover, it simplifies check that the injection really happened,
and its progress. You just look at iparam in Lua and see how many
times it has executed, and whether it is equal to 0 already
(with bparam you can do the same though, by setting it to false
explicitly).

  parent reply	other threads:[~2020-05-03 19:20 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 [this message]
2020-05-07 13:50     ` Nikita Pettik
2020-05-07 21:47       ` Vladislav Shpilevoy
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=cd76df9e-bd25-757b-b1f4-019028024dee@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