diff --git a/core/tarantool_lua.m b/core/tarantool_lua.m index ccfaebdd59086503852a08840e5ee61bd0a9b0c8..919437c0ab8d65f8197915dc913a81b72064964e 100644 --- a/core/tarantool_lua.m +++ b/core/tarantool_lua.m @@ -868,13 +868,11 @@ tarantool_lua_load_cfg(struct lua_State *L, struct tarantool_cfg *cfg) if (strchr(key, '.') == NULL) { lua_pushfstring(L, "box.cfg.%s = %s%s%s\n", key, quote, value, quote); - luaL_addstring(&b, lua_tostring(L, -1)); - lua_pop(L, 1); + luaL_addvalue(&b); } else if (strncmp(key, "space", strlen("space")) == 0) { lua_pushfstring(L, "box.%s = %s%s%s\n", key, quote, value, quote); - luaL_addstring(&b, lua_tostring(L, -1)); - lua_pop(L, 1); + luaL_addvalue(&b); } free(value); } @@ -887,8 +885,10 @@ tarantool_lua_load_cfg(struct lua_State *L, struct tarantool_cfg *cfg) " box.on_reload_configuration()\n" "end\n"); luaL_pushresult(&b); - if (luaL_loadstring(L, lua_tostring(L, -1)) == 0) - lua_pcall(L, 0, 0, 0); + if (luaL_loadstring(L, lua_tostring(L, -1)) != 0 || + lua_pcall(L, 0, 0, 0) != 0) { + panic("%s", lua_tostring(L, -1)); + } lua_pop(L, 1); } diff --git a/mod/box/box.lua b/mod/box/box.lua index 1556becb922fc018ae3118a5c439e29b95687607..8045fb52017195b80aa88b49ddfae94db5e7fcdd 100644 --- a/mod/box/box.lua +++ b/mod/box/box.lua @@ -123,9 +123,11 @@ function box.on_reload_configuration() for i, space in pairs(box.space) do rawset(space, 'n', i) setmetatable(space, space_mt) - for j, index in pairs(space.index) do - rawset(index, 'idx', box.index.new(i, j)) - setmetatable(index, index_mt) + if type(space.index) == 'table' and space.enabled then + for j, index in pairs(space.index) do + rawset(index, 'idx', box.index.new(i, j)) + setmetatable(index, index_mt) + end end end end diff --git a/test/box/configuration.result b/test/box/configuration.result index ded392434a19c82b584904728c4139217c2533ab..d9cde0798298b81cb3eecf2b7e4dd9a5006fefef 100644 --- a/test/box/configuration.result +++ b/test/box/configuration.result @@ -186,6 +186,18 @@ lua box.cfg.wal_fsync_delay - 0.01 ... +# Bug#928413 Lua malfunction on certain configuration +# (https://bugs.launchpad.net/bugs/928413) + +lua box.cfg.wal_fsync_delay +--- + - 0.1 +... +lua box.space[0].enabled +--- + - true +... + # Test field type conflict in keys tarantool_box -c tarantool_bad_type.cfg diff --git a/test/box/configuration.test b/test/box/configuration.test index 7eb7cb3bd6b08ee65704cfa5d3b4711753a6181f..97356e8737da50b602b2d9c83a66a2db26de45a9 100644 --- a/test/box/configuration.test +++ b/test/box/configuration.test @@ -41,6 +41,18 @@ server.deploy("box/tarantool_bug876541.cfg") # check values exec admin "lua box.cfg.wal_fsync_delay" +print """ +# Bug#928413 Lua malfunction on certain configuration +# (https://bugs.launchpad.net/bugs/928413) +""" +# stop current server +server.stop() +# start server from config with different boolean represenation +server.deploy("box/tarantool_bug928413.cfg") +# check values +exec admin "lua box.cfg.wal_fsync_delay" +exec admin "lua box.space[0].enabled" + print """ # Test field type conflict in keys """ diff --git a/test/box/tarantool_bug928413.cfg b/test/box/tarantool_bug928413.cfg new file mode 100644 index 0000000000000000000000000000000000000000..3038550eda411646755eb648fb0672a6252bad55 --- /dev/null +++ b/test/box/tarantool_bug928413.cfg @@ -0,0 +1,158 @@ +slab_alloc_arena = 0.1 + +pid_file = "box.pid" + +logger="cat - >> tarantool.log" + +primary_port = 33013 +secondary_port = 33014 +admin_port = 33015 + +log_level = 4 + +local_hot_standby = true + +slab_alloc_minimal = 48 + +# Growth factor, each subsecuent unit size is factor * prev unit size +slab_alloc_factor = 1.04 + + +# SESSIONS!!! ##################################### +#memcached_space = 52 +space[0].enabled = 1 +#namespace[0].expire_field = 2 + +space[0].index[0].type = "HASH" +space[0].index[0].unique = 1 +space[0].index[0].key_field[0].type = "STR" +space[0].index[0].key_field[0].fieldno = 0 + +space[0].index[1].type = "TREE" +space[0].index[1].unique = 0 +space[0].index[1].key_field[0].type = "STR" +space[0].index[1].key_field[0].fieldno = 1 +################################################### + +# video meta. Indexes: 1.ACCID +space[46] = { + enabled = 1 + index = [{ + type = "HASH" + unique = 1 + key_field = [{ + fieldno = 0 + type = "NUM" + }] + }] + } + +# upload meta. Indexes: 1.ITEMID 2.ACCID 3.UPLOADTIME +space[47] = { + enabled = 1 + index = [{ + type="HASH" + unique = 1 + Key_field = [{ + fieldno = 0 + type = "NUM64" + }] + },{ + type="TREE" + unique = 0 + Key_field = [{ + fieldno = 1 + type = "NUM" + }] + },{ + type="TREE" + unique = 0 + Key_field = [{ + fieldno = 2 + type = "NUM" + }] + }] + } + +# user meta. Indexes: 0.ITEMID 1.ACCID 2.EXTERNALID 3.FLAGS 4.STATUS 5.SERVICEID +space[48] = { + enabled = 1 + index = [{ + type="HASH" + unique = 1 + Key_field = [{ + fieldno = 0 + type = "NUM" + }] + },{ + type="TREE" + unique=0 + Key_field = [{ + fieldno = 1 + type = "NUM" + }] + }, + { + type="HASH" + unique = 1 + Key_field = [{ + fieldno = 2 + type = "STR" + }] + },{ + type="TREE" + unique = 0 + key_field = [{ + fieldno = 3 + type = "NUM" + }] + },{ + type="TREE" + unique = 0 + key_field = [{ + fieldno = 4 + type = "NUM" + }] + },{ + type="TREE" + unique = 0 + key_field = [{ + fieldno = 5 + type = "NUM" + }] + } + ] + + } +space[50] = { + enabled = 1 + index = [{ + type="HASH" + unique = 1 + Key_field = [{ + fieldno = 0 + type = "NUM" + }] + }] + } + + +space[53] = { + enabled = 1 + index = [{ + type = "HASH" + unique = 1 + key_field = [{ + fieldno = 0 + type= "NUM" + }] + }] + } + +wal_fsync_delay = 0.1 +io_collect_interval = 0.001 +logger_nonblock = true +coredump = true +snap_io_rate_limit = 50.0 +custom_proc_title = "videobox" +