From ac8f82bb53bc0f18b4382d68e99b12659e389061 Mon Sep 17 00:00:00 2001 From: Nikita Zheleztsov Date: Fri, 29 Dec 2023 03:15:11 +0300 Subject: [PATCH] storage: fix hot reload with named identification Currently hot reload failes, when named identification is used. It is cause by the fact, that we still pass uuid in storage.cfg during reload. Let's pass id instead of UUID. It's either uuid or name, depending on identification_mode. If reload is done from the old version, where no replica.id exists, we fall back to replica.uuid. Closes #464 NO_DOC=bugfix --- test/storage-luatest/storage_1_test.lua | 25 +++++++++++++++++++++++++ vshard/storage/init.lua | 3 ++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/test/storage-luatest/storage_1_test.lua b/test/storage-luatest/storage_1_test.lua index b3a3f536..f8e758e5 100644 --- a/test/storage-luatest/storage_1_test.lua +++ b/test/storage-luatest/storage_1_test.lua @@ -183,3 +183,28 @@ test_group.test_local_call = function(g) box.func.sum:drop() end) end + +-- +-- gh-464: hot reload with named identification is broken. +-- +test_group.test_named_hot_reload = function(g) + t.run_only_if(vutil.feature.persistent_names) + local new_cfg_template = table.deepcopy(cfg_template) + new_cfg_template.identification_mode = 'name_as_key' + new_cfg_template.sharding['replicaset'] = new_cfg_template.sharding[1] + new_cfg_template.sharding[1] = nil + + g.replica_1_a:exec(function() + box.cfg{instance_name = 'replica_1_a', replicaset_name = 'replicaset'} + end) + local new_global_cfg = vtest.config_new(new_cfg_template) + vtest.cluster_cfg(g, new_global_cfg) + + -- gh-464: hot reload with named identification is broken. + g.replica_1_a:exec(function() + package.loaded['vshard.storage'] = nil + local ok, storage = pcall(require, 'vshard.storage') + ilt.assert_equals(ok, true) + _G.vshard.storage = storage + end) +end diff --git a/vshard/storage/init.lua b/vshard/storage/init.lua index cdb5fec8..34560cb9 100644 --- a/vshard/storage/init.lua +++ b/vshard/storage/init.lua @@ -4036,7 +4036,8 @@ if not rawget(_G, MODULE_INTERNALS) then else reload_evolution.upgrade(M) if M.current_cfg then - storage_cfg(M.current_cfg, M.this_replica.uuid, true) + storage_cfg(M.current_cfg, M.this_replica.id or M.this_replica.uuid, + true) end M.module_version = M.module_version + 1 -- Background fibers could sleep waiting for bucket changes.