Tarantool development patches archive
 help / color / mirror / Atom feed
From: Nikita Pettik <korablev@tarantool.org>
To: Ilya Kosarev <i.kosarev@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org, v.shpilevoy@tarantool.org
Subject: Re: [Tarantool-patches] [PATCH v3 2/2] memtx: allow quota overuse for truncation and deletion
Date: Tue, 21 Jan 2020 14:42:53 +0300	[thread overview]
Message-ID: <20200121114253.GH82780@tarantool.org> (raw)
In-Reply-To: <45d9f491f91d93c8835ca725c234f7113c0d2aa8.1579541242.git.i.kosarev@tarantool.org>

On 20 Jan 21:13, Ilya Kosarev wrote:
> diff --git a/src/box/box.cc b/src/box/box.cc
> index 1b2b27d61..678c9ffe3 100644
> --- a/src/box/box.cc
> +++ b/src/box/box.cc
> @@ -1321,9 +1321,14 @@ space_truncate(struct space *space)
>  	ops_buf_end = mp_encode_uint(ops_buf_end, 1);
>  	assert(ops_buf_end < buf + buf_size);
>  
> +	struct space *truncate_space = space_cache_find_xc(BOX_TRUNCATE_ID);
> +	memtx_engine_set_quota_strictness(truncate_space->engine, false);

I wouldn't call it strictness. In fact you simply turn quota on/off.
So I'd better call it quota_enable/disable.

Nit: please accompany your code with (at least brief) comments.

> +
>  	if (box_upsert(BOX_TRUNCATE_ID, 0, tuple_buf, tuple_buf_end,
>  		       ops_buf, ops_buf_end, 0, NULL) != 0)
>  		diag_raise();

If box_upsert() fails, quota is not re-enabled, isn't it?

> +
> +	memtx_engine_set_quota_strictness(truncate_space->engine, true);
>  }
>  
>  int
> diff --git a/src/box/memtx_engine.c b/src/box/memtx_engine.c
> index 4da80824a..c19205d34 100644
> --- a/src/box/memtx_engine.c
> +++ b/src/box/memtx_engine.c
> @@ -1090,6 +1090,15 @@ memtx_engine_set_memory(struct memtx_engine *memtx, size_t size)
>  	return 0;
>  }
>  
> +void
> +memtx_engine_set_quota_strictness(struct engine *engine, bool strict)
> +{
> +	if (strncmp(engine->name, "memtx", 5) != 0)
> +		return;

memtx_ prefix in the name of this function assumes that it is called
only for memtx engine. Note that there's no such checks in memtx_engine
interface functions.

> +	struct memtx_engine *memtx = (struct memtx_engine *)engine;
> +	quota_set_strictness(&memtx->quota, strict);
 
What happens if quota is turned on back, but it still exceeds limit?
I guess it would turn out to be in inconsistent state, since in
normal operation mode there's no chance of being beyond the limit.

> +
>  void
>  memtx_engine_set_max_tuple_size(struct memtx_engine *memtx, size_t max_size)
>  {
> diff --git a/src/box/memtx_engine.h b/src/box/memtx_engine.h
> index f562c66df..0793fc2ab 100644
> --- a/src/box/memtx_engine.h
> +++ b/src/box/memtx_engine.h
> @@ -213,6 +213,9 @@ memtx_engine_set_snap_io_rate_limit(struct memtx_engine *memtx, double limit);
>  int
>  memtx_engine_set_memory(struct memtx_engine *memtx, size_t size);
>  
> +void
> +memtx_engine_set_quota_strictness(struct engine *engine, bool strict);
> +
>  void
>  memtx_engine_set_max_tuple_size(struct memtx_engine *memtx, size_t max_size);
>  
> diff --git a/src/lib/small b/src/lib/small
> index 50cb78743..bdcd569f9 160000
> --- a/src/lib/small
> +++ b/src/lib/small

What about adding unit and regression tests?

> @@ -1 +1 @@
> -Subproject commit 50cb7874380b286f3b34c82299cf5eb88b0d0059
> +Subproject commit bdcd569f9ed753efb805f708089ca86e2520a44f
> -- 
> 2.17.1
> 

  reply	other threads:[~2020-01-21 11:42 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-20 18:13 [Tarantool-patches] [PATCH v3 0/2] Safe " Ilya Kosarev
2020-01-20 18:13 ` [Tarantool-patches] [PATCH v3 1/2] b-tree: return NULL on matras_alloc fail Ilya Kosarev
2020-01-21 10:32   ` Nikita Pettik
2020-01-31  8:18     ` Konstantin Osipov
2020-02-04 17:13       ` Nikita Pettik
2020-02-04 17:25         ` Konstantin Osipov
2020-02-04 18:08           ` Nikita Pettik
2020-02-04 18:25             ` Konstantin Osipov
2020-01-21 20:55   ` Vladislav Shpilevoy
2020-01-20 18:13 ` [Tarantool-patches] [PATCH v3 2/2] memtx: allow quota overuse for truncation and deletion Ilya Kosarev
2020-01-21 11:42   ` Nikita Pettik [this message]
2020-01-21 20:59     ` Vladislav Shpilevoy
2020-02-14 19:57       ` Ilya Kosarev
2020-01-31  8:21   ` Konstantin Osipov
2020-02-04 18:56     ` Ilya Kosarev
2020-02-04 20:06       ` Konstantin Osipov
2020-02-05 19:11         ` Ilya Kosarev
2020-02-05 19:17           ` Konstantin Osipov
2020-02-06 10:50             ` Ilya Kosarev
2020-02-06 14:29               ` Konstantin Osipov
2020-02-06 16:14                 ` Ilya Kosarev
2020-02-06 16:26                   ` Konstantin Osipov
2020-02-10  8:24                     ` Ilya Kosarev
2020-02-10  9:49                       ` Konstantin Osipov
2020-02-10 10:43                         ` Ilya Kosarev
2020-02-10 10:50                           ` Konstantin Osipov
2020-02-14 19:55                             ` Ilya Kosarev

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=20200121114253.GH82780@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=i.kosarev@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v3 2/2] memtx: allow quota overuse for truncation and deletion' \
    /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