diff --git a/changelogs/unreleased/info-cluster-rename.md b/changelogs/unreleased/info-cluster-rename.md new file mode 100644 index 0000000000000000000000000000000000000000..377fe92dd31402ef6229745506c1879beb7c0e06 --- /dev/null +++ b/changelogs/unreleased/info-cluster-rename.md @@ -0,0 +1,6 @@ +## bugfix/core + +* **[Breaking change]** The table `box.info.cluster` is renamed to + `box.info.replicaset`. The behaviour can be reverted using the `compat` option + `box_info_cluster_meaning` + (https://tarantool.io/compat/box_info_cluster_meaning) (gh-5029). diff --git a/src/box/lua/feedback_daemon.lua b/src/box/lua/feedback_daemon.lua index 14f2021d80320fca602a8812b9eecb7760f9526d..adfaadfb4e4d0c387b43b6aafffc80e345222a94 100644 --- a/src/box/lua/feedback_daemon.lua +++ b/src/box/lua/feedback_daemon.lua @@ -114,7 +114,7 @@ local function fill_in_base_info(feedback) end feedback.tarantool_version = box.info.version feedback.server_id = box.info.uuid - feedback.cluster_id = box.info.cluster.uuid + feedback.cluster_id = box.info.replicaset.uuid feedback.uptime = box.info.uptime end diff --git a/src/box/lua/info.c b/src/box/lua/info.c index e04d06a02d2d4190ca1f3c78b82c1692b6cfed95..0db8f947a40d3cfdfdec757b1fce2a1f258f34a0 100644 --- a/src/box/lua/info.c +++ b/src/box/lua/info.c @@ -57,6 +57,16 @@ #include "fiber.h" #include "sio.h" #include "tt_strerror.h" +#include "tweaks.h" + +/** + * In 3.0.0 the meaning of box.info.cluster changed to something not related. In + * the major release it was allowed to make the new behaviour the default one, + * but since the change can be very breaking for some people, it still can be + * reverted. + */ +static bool box_info_cluster_new_meaning = true; +TWEAK_BOOL(box_info_cluster_new_meaning); static inline void lbox_push_replication_error_message(struct lua_State *L, struct error *e, @@ -369,8 +379,9 @@ lbox_info_pid(struct lua_State *L) return 1; } +/** box.info.replicaset. */ static int -lbox_info_cluster(struct lua_State *L) +lbox_info_replicaset(struct lua_State *L) { lua_createtable(L, 0, 2); lua_pushliteral(L, "uuid"); @@ -379,6 +390,16 @@ lbox_info_cluster(struct lua_State *L) return 1; } +/** box.info.cluster. */ +static int +lbox_info_cluster(struct lua_State *L) +{ + if (!box_info_cluster_new_meaning) + return lbox_info_replicaset(L); + lua_createtable(L, 0, 0); + return 1; +} + static int lbox_info_memory_call(struct lua_State *L) { @@ -662,6 +683,7 @@ static const struct luaL_Reg lbox_info_dynamic_meta[] = { {"ro_reason", lbox_info_ro_reason}, {"replication", lbox_info_replication}, {"replication_anon", lbox_info_replication_anon}, + {"replicaset", lbox_info_replicaset}, {"status", lbox_info_status}, {"uptime", lbox_info_uptime}, {"pid", lbox_info_pid}, diff --git a/src/box/lua/load_cfg.lua b/src/box/lua/load_cfg.lua index 4a0c0f6e83b935f9173e419f91a6129f9aef215f..f3a5e2f1ba5d73977018bf62b6692037709f2a04 100644 --- a/src/box/lua/load_cfg.lua +++ b/src/box/lua/load_cfg.lua @@ -432,7 +432,7 @@ local function check_instance_uuid() end local function check_replicaset_uuid() - if box.cfg.replicaset_uuid ~= box.info.cluster.uuid then + if box.cfg.replicaset_uuid ~= box.info.replicaset.uuid then box.error(box.error.RELOAD_CFG, 'replicaset_uuid') end end diff --git a/src/lua/compat.lua b/src/lua/compat.lua index ef2d69d18944d6bed38606a1ab2c0689e1aed9a2..c690db39e780db7aa42b24ea1e8c97c3c58b2d1b 100644 --- a/src/lua/compat.lua +++ b/src/lua/compat.lua @@ -51,6 +51,13 @@ initialization or new session creation. https://tarantool.io/compat/sql_seq_scan_default ]] +local BOX_INFO_CLUSTER_MEANING_BRIEF = [[ +Whether box.info.cluster should show the current replicaset or the whole cluster +with all its replicasets. + +https://tarantool.io/compat/box_info_cluster_meaning +]] + -- Returns an action callback that toggles a tweak. local function tweak_action(tweak_name, old_tweak_value, new_tweak_value) return function(is_new) @@ -96,6 +103,12 @@ local options = { brief = SQL_SEQ_SCAN_DEFAULT_BRIEF, action = tweak_action('sql_seq_scan_default', true, false), }, + box_info_cluster_meaning = { + default = 'new', + obsolete = nil, + brief = BOX_INFO_CLUSTER_MEANING_BRIEF, + action = tweak_action('box_info_cluster_new_meaning', false, true), + }, } -- Array with option names in order of addition. diff --git a/test/app-tap/gh-5632-6050-6259-gc-buf-reuse.test.lua b/test/app-tap/gh-5632-6050-6259-gc-buf-reuse.test.lua index 84c2944e5249df9dea1ef0579c8589f0d34cf6d3..38db2cb0d34cd0831af4380d77456cfe1923949c 100755 --- a/test/app-tap/gh-5632-6050-6259-gc-buf-reuse.test.lua +++ b/test/app-tap/gh-5632-6050-6259-gc-buf-reuse.test.lua @@ -200,9 +200,9 @@ local function test_info_uuid(test) local function uuid_to_str() local str1 = box.info.uuid - local str2 = box.info.cluster.uuid + local str2 = box.info.replicaset.uuid local str3 = box.info.uuid - local str4 = box.info.cluster.uuid + local str4 = box.info.replicaset.uuid if str1 ~= str3 or str2 ~= str4 then is_success = false end diff --git a/test/box-luatest/downgrade_test.lua b/test/box-luatest/downgrade_test.lua index 71b2f28590d2d8ed572c49bb8091e79458ef03ac..340c7c1738e89e79cde1e04643bae585e4d3bb0b 100644 --- a/test/box-luatest/downgrade_test.lua +++ b/test/box-luatest/downgrade_test.lua @@ -896,7 +896,7 @@ g.test_downgrade_replicaset_uuid_key = function(cg) cg.server:exec(function() local helper = require('test.box-luatest.downgrade_helper') local _schema = box.space._schema - local rs_uuid = box.info.cluster.uuid + local rs_uuid = box.info.replicaset.uuid local prev_version = helper.prev_version(helper.app_version('3.0.0')) t.assert_equals(box.schema.downgrade_issues(prev_version), {}) t.assert_equals(_schema:get{'cluster'}, nil) diff --git a/test/box-luatest/schema_sys_space_test.lua b/test/box-luatest/schema_sys_space_test.lua index 52eaba8db3c69fdfdadda929ddc91d3099ae8e20..fe5fcfac21ff4dfefc3f0449ddee42e7e3c74abf 100644 --- a/test/box-luatest/schema_sys_space_test.lua +++ b/test/box-luatest/schema_sys_space_test.lua @@ -21,7 +21,7 @@ g.test_replicaset_uuid_update_ban = function(lg) t.assert_error_msg_contains(msg, _schema.replace, _schema, {'replicaset_uuid', tostring(uuid.NULL)}) -- Fine to replace with the same value. - _schema:replace{'replicaset_uuid', box.info.cluster.uuid} + _schema:replace{'replicaset_uuid', box.info.replicaset.uuid} end) end @@ -50,7 +50,7 @@ g.test_old_cluster_uuid_key = function(lg) local msg = "Can't reset replica set UUID" t.assert_error_msg_contains(msg, _schema.replace, _schema, {'cluster', uuid.str()}) - _schema:replace{'cluster', box.info.cluster.uuid} + _schema:replace{'cluster', box.info.replicaset.uuid} _schema:delete{'cluster'} end) end diff --git a/test/box-luatest/upgrade_to_3_0_0_test.lua b/test/box-luatest/upgrade_to_3_0_0_test.lua index b338f1a9c21ec2fdc886db607da261e315d33b84..a7f1999f2a951494dcfb3d7240e3638f04e47726 100644 --- a/test/box-luatest/upgrade_to_3_0_0_test.lua +++ b/test/box-luatest/upgrade_to_3_0_0_test.lua @@ -23,6 +23,6 @@ g.test_new_replicaset_uuid_key = function(cg) local _schema = box.space._schema t.assert_equals(_schema:get{'cluster'}, nil) t.assert_equals(_schema:get{'replicaset_uuid'}.value, - box.info.cluster.uuid) + box.info.replicaset.uuid) end) end diff --git a/test/box-tap/cfg.test.lua b/test/box-tap/cfg.test.lua index c6f511ec90c73301e06cb9707a7fe16f45e52a1b..cd6706073dc266cba1c4b5d00b1c1b762ad6afe4 100755 --- a/test/box-tap/cfg.test.lua +++ b/test/box-tap/cfg.test.lua @@ -444,7 +444,7 @@ test:is(run_script(code), 0, "check instance_uuid") code = [[ replicaset_uuid = tostring(require('uuid').new()) box.cfg{replicaset_uuid = replicaset_uuid} -os.exit(replicaset_uuid == box.info.cluster.uuid and 0 or 1) +os.exit(replicaset_uuid == box.info.replicaset.uuid and 0 or 1) ]] test:is(run_script(code), 0, "check replicaset_uuid") diff --git a/test/box/cfg.result b/test/box/cfg.result index fb3387a5e95bfab76f9d58759b8ce448efc1ecb6..969371e90ce2ec75dfb817cb64bef0818bbd97d6 100644 --- a/test/box/cfg.result +++ b/test/box/cfg.result @@ -418,7 +418,7 @@ box.cfg{instance_uuid = '12345678-0123-5678-1234-abcdefabcdef'} | - error: Can't set option 'instance_uuid' dynamically | ... -box.cfg{replicaset_uuid = box.info.cluster.uuid} +box.cfg{replicaset_uuid = box.info.replicaset.uuid} | --- | ... box.cfg{replicaset_uuid = '12345678-0123-5678-1234-abcdefabcdef'} diff --git a/test/box/cfg.test.lua b/test/box/cfg.test.lua index 6342bb3df90a2688fca80e342d3e99fa08c2fc69..29f0e0a31d76e0339463f6f8f115d99dd8cf8156 100644 --- a/test/box/cfg.test.lua +++ b/test/box/cfg.test.lua @@ -50,7 +50,7 @@ box.cfg{replication_sync_timeout = replication_sync_timeout} box.cfg{instance_uuid = box.info.uuid} box.cfg{instance_uuid = '12345678-0123-5678-1234-abcdefabcdef'} -box.cfg{replicaset_uuid = box.info.cluster.uuid} +box.cfg{replicaset_uuid = box.info.replicaset.uuid} box.cfg{replicaset_uuid = '12345678-0123-5678-1234-abcdefabcdef'} box.cfg{memtx_memory = box.cfg.memtx_memory} diff --git a/test/box/info.result b/test/box/info.result index 17c365a601ce1e0b456f3990097b87e4bc70f07d..73c8aa48d52f963e8ef6681db2585432fd8550be 100644 --- a/test/box/info.result +++ b/test/box/info.result @@ -59,7 +59,7 @@ string.match(box.info.uptime, '^[1-9][0-9]*$') ~= nil --- - true ... -box.info.cluster.uuid == box.space._schema:get{'replicaset_uuid'}[2] +box.info.replicaset.uuid == box.space._schema:get{'replicaset_uuid'}[2] --- - true ... @@ -83,6 +83,7 @@ t - memory - package - pid + - replicaset - replication - replication_anon - ro @@ -234,3 +235,38 @@ ch:get() -- false --- - false ... +-- +-- box.info.cluster compat. Before 3.0.0 it meant the current replicaset. Now it +-- means the whole cluster. +-- +compat = require('compat') +--- +... +info = compat.box_info_cluster_meaning +--- +... +assert(info.current == 'default') +--- +- true +... +assert(info.default == 'new') +--- +- true +... +rs_uuid = box.info.replicaset.uuid +--- +... +assert(box.info.cluster.uuid ~= rs_uuid) +--- +- true +... +compat.box_info_cluster_meaning = 'old' +--- +... +assert(box.info.cluster.uuid == rs_uuid) +--- +- true +... +compat.box_info_cluster_meaning = 'default' +--- +... diff --git a/test/box/info.test.lua b/test/box/info.test.lua index 66935af10fb99b82925a706d4b85bcd608086a69..19056301bd207d97e9741b2938fe0b700eebec12 100644 --- a/test/box/info.test.lua +++ b/test/box/info.test.lua @@ -16,7 +16,7 @@ box.info.replication[1].id box.info.status string.len(box.info.uptime) > 0 string.match(box.info.uptime, '^[1-9][0-9]*$') ~= nil -box.info.cluster.uuid == box.space._schema:get{'replicaset_uuid'}[2] +box.info.replicaset.uuid == box.space._schema:get{'replicaset_uuid'}[2] t = {} for k, _ in pairs(box.info()) do table.insert(t, k) end table.sort(t) @@ -67,3 +67,17 @@ _ = fiber.create(function() box.ctl.wait_rw() ch:put(box.info.ro) end) fiber.sleep(0.001) box.cfg{read_only = false} ch:get() -- false + +-- +-- box.info.cluster compat. Before 3.0.0 it meant the current replicaset. Now it +-- means the whole cluster. +-- +compat = require('compat') +info = compat.box_info_cluster_meaning +assert(info.current == 'default') +assert(info.default == 'new') +rs_uuid = box.info.replicaset.uuid +assert(box.info.cluster.uuid ~= rs_uuid) +compat.box_info_cluster_meaning = 'old' +assert(box.info.cluster.uuid == rs_uuid) +compat.box_info_cluster_meaning = 'default' diff --git a/test/replication-luatest/bootstrap_strategy_test.lua b/test/replication-luatest/bootstrap_strategy_test.lua index 53d455c380361cce538c40295e20dff360eecd3b..75a88ae66315ab62200090712999e62b2c2ae654 100644 --- a/test/replication-luatest/bootstrap_strategy_test.lua +++ b/test/replication-luatest/bootstrap_strategy_test.lua @@ -388,7 +388,7 @@ g_config_success.test_correct_bootstrap_leader = function(cg) cg.replica_set_b:start{} cg.replica_set:start{} t.helpers.retrying({}, cg.server1.exec, cg.server1, function(uuid) - t.assert_equals(box.info.cluster.uuid, uuid, + t.assert_equals(box.info.replicaset.uuid, uuid, 'Server bootstrapped from correct leader') end, {uuidb}) end @@ -425,7 +425,7 @@ end) g_config_success.test_wait_only_for_leader = function(cg) cg.replica_set:start{} t.helpers.retrying({}, cg.server1.exec, cg.server1, function(uuid) - t.assert_equals(box.info.cluster.uuid, uuid, + t.assert_equals(box.info.replicaset.uuid, uuid, 'Server boots as soon as sees the leader') end, {uuidb}) end