* [PATCH v2] box: allow vinyl_memory set to 0 in config
@ 2018-07-04 13:23 Serge Petrenko
2018-07-04 13:37 ` Vladimir Davydov
0 siblings, 1 reply; 4+ messages in thread
From: Serge Petrenko @ 2018-07-04 13:23 UTC (permalink / raw)
To: vdavydov.dev; +Cc: tarantool-patches, Serge Petrenko
Sorry, forgot to post diff.
In 1.9 it was possible to have a vinylless configuration with
vinyl_memory=0, allow to do this in 1.10 by adjusting sanity
checks for vinyl_memory and memtx_memory. Now banning only
negative values.
memtx_memory check was changed for consistency, trying to
set memtx_memory to 0 fails anyways.
Also added a test to check that vinyl_memory can actually
be set to 0.
Closes: #3468
---
https://github.com/tarantool/tarantool/tree/sergepetrenko/gh-3468-allow-0-vinyl-memory
https://github.com/tarantool/tarantool/issues/3468
Changes in v2:
- added a test case to check vinyl_memory=0 is legal.
src/box/box.cc | 8 ++++----
test/box-tap/cfg.test.lua | 8 +++++++-
test/box/cfg.result | 4 ++--
3 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/src/box/box.cc b/src/box/box.cc
index dcbf52e10..7d6dfc8f6 100644
--- a/src/box/box.cc
+++ b/src/box/box.cc
@@ -495,9 +495,9 @@ box_check_wal_max_size(int64_t wal_max_size)
static int64_t
box_check_memtx_memory(int64_t memory)
{
- if (memory <= 0) {
+ if (memory < 0) {
tnt_raise(ClientError, ER_CFG, "memtx_memory",
- "must be greater than 0");
+ "must not be less than 0");
}
return memory;
}
@@ -505,9 +505,9 @@ box_check_memtx_memory(int64_t memory)
static int64_t
box_check_vinyl_memory(int64_t memory)
{
- if (memory <= 0) {
+ if (memory < 0) {
tnt_raise(ClientError, ER_CFG, "vinyl_memory",
- "must be greater than 0");
+ "must not be less than 0");
}
return memory;
}
diff --git a/test/box-tap/cfg.test.lua b/test/box-tap/cfg.test.lua
index b93a21f35..764fade93 100755
--- a/test/box-tap/cfg.test.lua
+++ b/test/box-tap/cfg.test.lua
@@ -6,7 +6,7 @@ local socket = require('socket')
local fio = require('fio')
local uuid = require('uuid')
local msgpack = require('msgpack')
-test:plan(91)
+test:plan(93)
--------------------------------------------------------------------------------
-- Invalid values
@@ -82,9 +82,15 @@ os.execute("rm -rf vinyl")
box.cfg{
log="tarantool.log",
memtx_memory=104857600,
+ vinyl_memory=0,
wal_mode = "", -- "" means default value
}
+status, result = pcall(testfun)
+test:ok(status and result == "table", "allow vinyl_memory set to 0 in box.cfg")
+test:is(box.cfg.vinyl_memory, 0, "vinyl_memory actually set to 0")
+
+box.cfg{vinyl_memory=128 * 1024 * 1024}
-- gh-678: vinyl engine creates vinyl dir with empty 'snapshot' file
test:isnil(io.open("vinyl", 'r'), 'vinyl_dir is not auto-created')
diff --git a/test/box/cfg.result b/test/box/cfg.result
index 7604f61dc..6debb564b 100644
--- a/test/box/cfg.result
+++ b/test/box/cfg.result
@@ -240,11 +240,11 @@ box.cfg{memtx_memory = "100500"}
...
box.cfg{memtx_memory = -1}
---
-- error: 'Incorrect value for option ''memtx_memory'': must be greater than 0'
+- error: 'Incorrect value for option ''memtx_memory'': must not be less than 0'
...
box.cfg{vinyl_memory = -1}
---
-- error: 'Incorrect value for option ''vinyl_memory'': must be greater than 0'
+- error: 'Incorrect value for option ''vinyl_memory'': must not be less than 0'
...
box.cfg{vinyl = "vinyl"}
---
--
2.15.2 (Apple Git-101.1)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] box: allow vinyl_memory set to 0 in config
2018-07-04 13:23 [PATCH v2] box: allow vinyl_memory set to 0 in config Serge Petrenko
@ 2018-07-04 13:37 ` Vladimir Davydov
2018-07-04 14:11 ` Sergey Petrenko
0 siblings, 1 reply; 4+ messages in thread
From: Vladimir Davydov @ 2018-07-04 13:37 UTC (permalink / raw)
To: Serge Petrenko; +Cc: tarantool-patches
On Wed, Jul 04, 2018 at 04:23:48PM +0300, Serge Petrenko wrote:
> Sorry, forgot to post diff.
All extra information that you want to get to the reviewer should go
after --- (where you put branch and change log). This way it will be
ignored by `git am` (we don't use it now, but people in other projects
do and we might want to start using it instead of `git merge` one day).
>
> In 1.9 it was possible to have a vinylless configuration with
> vinyl_memory=0, allow to do this in 1.10 by adjusting sanity
> checks for vinyl_memory and memtx_memory. Now banning only
> negative values.
> memtx_memory check was changed for consistency, trying to
> set memtx_memory to 0 fails anyways.
> Also added a test to check that vinyl_memory can actually
> be set to 0.
>
> Closes: #3468
> ---
> https://github.com/tarantool/tarantool/tree/sergepetrenko/gh-3468-allow-0-vinyl-memory
> https://github.com/tarantool/tarantool/issues/3468
>
> Changes in v2:
> - added a test case to check vinyl_memory=0 is legal.
> diff --git a/test/box-tap/cfg.test.lua b/test/box-tap/cfg.test.lua
> index b93a21f35..764fade93 100755
> --- a/test/box-tap/cfg.test.lua
> +++ b/test/box-tap/cfg.test.lua
> @@ -6,7 +6,7 @@ local socket = require('socket')
> local fio = require('fio')
> local uuid = require('uuid')
> local msgpack = require('msgpack')
> -test:plan(91)
> +test:plan(93)
>
> --------------------------------------------------------------------------------
> -- Invalid values
> @@ -82,9 +82,15 @@ os.execute("rm -rf vinyl")
> box.cfg{
> log="tarantool.log",
> memtx_memory=104857600,
> + vinyl_memory=0,
> wal_mode = "", -- "" means default value
> }
>
> +status, result = pcall(testfun)
> +test:ok(status and result == "table", "allow vinyl_memory set to 0 in box.cfg")
> +test:is(box.cfg.vinyl_memory, 0, "vinyl_memory actually set to 0")
> +
> +box.cfg{vinyl_memory=128 * 1024 * 1024}
> -- gh-678: vinyl engine creates vinyl dir with empty 'snapshot' file
> test:isnil(io.open("vinyl", 'r'), 'vinyl_dir is not auto-created')
That's not exactly what I meant. There's an easier way to test initial
box configuration:
code = [[ box.cfg{ vinyl_memory=0 } ]]
test:is(run_script(code), 0, 'vinyl_memory is 0')
(there are plenty of similar test cases in box-tap/cfg.test.lua)
Also, when you add a test case, please write a brief description with a
reference to the github ticket you're fixing, e.g.
(also from box-tap/cfg.test.lua)
> -- gh-2664: vinyl_dir is checked on the first use
> code = [[ box.cfg{ vinyl_dir='invalid' } ]]
> test:is(run_script(code), 0, 'vinyl_dir is invalid')
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] box: allow vinyl_memory set to 0 in config
2018-07-04 13:37 ` Vladimir Davydov
@ 2018-07-04 14:11 ` Sergey Petrenko
2018-07-04 14:23 ` Vladimir Davydov
0 siblings, 1 reply; 4+ messages in thread
From: Sergey Petrenko @ 2018-07-04 14:11 UTC (permalink / raw)
To: Vladimir Davydov; +Cc: tarantool-patches
04.07.2018 16:37, Vladimir Davydov пишет:
> On Wed, Jul 04, 2018 at 04:23:48PM +0300, Serge Petrenko wrote:
>> Sorry, forgot to post diff.
> All extra information that you want to get to the reviewer should go
> after --- (where you put branch and change log). This way it will be
> ignored by `git am` (we don't use it now, but people in other projects
> do and we might want to start using it instead of `git merge` one day).
>
>> In 1.9 it was possible to have a vinylless configuration with
>> vinyl_memory=0, allow to do this in 1.10 by adjusting sanity
>> checks for vinyl_memory and memtx_memory. Now banning only
>> negative values.
>> memtx_memory check was changed for consistency, trying to
>> set memtx_memory to 0 fails anyways.
>> Also added a test to check that vinyl_memory can actually
>> be set to 0.
>>
>> Closes: #3468
>> ---
>> https://github.com/tarantool/tarantool/tree/sergepetrenko/gh-3468-allow-0-vinyl-memory
>> https://github.com/tarantool/tarantool/issues/3468
>>
>> Changes in v2:
>> - added a test case to check vinyl_memory=0 is legal.
>> diff --git a/test/box-tap/cfg.test.lua b/test/box-tap/cfg.test.lua
>> index b93a21f35..764fade93 100755
>> --- a/test/box-tap/cfg.test.lua
>> +++ b/test/box-tap/cfg.test.lua
>> @@ -6,7 +6,7 @@ local socket = require('socket')
>> local fio = require('fio')
>> local uuid = require('uuid')
>> local msgpack = require('msgpack')
>> -test:plan(91)
>> +test:plan(93)
>>
>> --------------------------------------------------------------------------------
>> -- Invalid values
>> @@ -82,9 +82,15 @@ os.execute("rm -rf vinyl")
>> box.cfg{
>> log="tarantool.log",
>> memtx_memory=104857600,
>> + vinyl_memory=0,
>> wal_mode = "", -- "" means default value
>> }
>>
>> +status, result = pcall(testfun)
>> +test:ok(status and result == "table", "allow vinyl_memory set to 0 in box.cfg")
>> +test:is(box.cfg.vinyl_memory, 0, "vinyl_memory actually set to 0")
>> +
>> +box.cfg{vinyl_memory=128 * 1024 * 1024}
>> -- gh-678: vinyl engine creates vinyl dir with empty 'snapshot' file
>> test:isnil(io.open("vinyl", 'r'), 'vinyl_dir is not auto-created')
> That's not exactly what I meant. There's an easier way to test initial
> box configuration:
>
> code = [[ box.cfg{ vinyl_memory=0 } ]]
> test:is(run_script(code), 0, 'vinyl_memory is 0')
>
> (there are plenty of similar test cases in box-tap/cfg.test.lua)
>
> Also, when you add a test case, please write a brief description with a
> reference to the github ticket you're fixing, e.g.
>
> (also from box-tap/cfg.test.lua)
>> -- gh-2664: vinyl_dir is checked on the first use
>> code = [[ box.cfg{ vinyl_dir='invalid' } ]]
>> test:is(run_script(code), 0, 'vinyl_dir is invalid')
Done
diff --git a/test/box-tap/cfg.test.lua b/test/box-tap/cfg.test.lua
index b93a21f35..5608f6578 100755
--- a/test/box-tap/cfg.test.lua
+++ b/test/box-tap/cfg.test.lua
@@ -6,7 +6,7 @@ local socket = require('socket')
local fio = require('fio')
local uuid = require('uuid')
local msgpack = require('msgpack')
-test:plan(91)
+test:plan(92)
--------------------------------------------------------------------------------
-- Invalid values
@@ -164,6 +164,13 @@ function run_script(code)
return res
end
+-- gh-3468: should allow box.cfg with vinyl_memory=0
+code =[[
+box.cfg{vinyl_memory=0}
+os.exit(box.cfg.vinyl_memory == 0 and 0 or 1)
+]]
+test:is(run_script(code), 0, "actually set vinyl_memory to 0")
+
-- gh-715: Cannot switch to/from 'fsync'
code = [[ box.cfg{ log="tarantool.log", wal_mode = 'fsync' }; ]]
test:is(run_script(code), 0, 'wal_mode fsync')
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] box: allow vinyl_memory set to 0 in config
2018-07-04 14:11 ` Sergey Petrenko
@ 2018-07-04 14:23 ` Vladimir Davydov
0 siblings, 0 replies; 4+ messages in thread
From: Vladimir Davydov @ 2018-07-04 14:23 UTC (permalink / raw)
To: Sergey Petrenko; +Cc: tarantool-patches
On Wed, Jul 04, 2018 at 05:11:10PM +0300, Sergey Petrenko wrote:
> diff --git a/test/box-tap/cfg.test.lua b/test/box-tap/cfg.test.lua
> index b93a21f35..5608f6578 100755
> --- a/test/box-tap/cfg.test.lua
> +++ b/test/box-tap/cfg.test.lua
> @@ -6,7 +6,7 @@ local socket = require('socket')
> local fio = require('fio')
> local uuid = require('uuid')
> local msgpack = require('msgpack')
> -test:plan(91)
> +test:plan(92)
>
> --------------------------------------------------------------------------------
> -- Invalid values
> @@ -164,6 +164,13 @@ function run_script(code)
> return res
> end
>
> +-- gh-3468: should allow box.cfg with vinyl_memory=0
> +code =[[
> +box.cfg{vinyl_memory=0}
> +os.exit(box.cfg.vinyl_memory == 0 and 0 or 1)
> +]]
> +test:is(run_script(code), 0, "actually set vinyl_memory to 0")
Looks good to me.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-07-04 14:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-04 13:23 [PATCH v2] box: allow vinyl_memory set to 0 in config Serge Petrenko
2018-07-04 13:37 ` Vladimir Davydov
2018-07-04 14:11 ` Sergey Petrenko
2018-07-04 14:23 ` Vladimir Davydov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox