Skip to content

Commit

Permalink
storage: fix hot reload with named identification
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Serpentian authored and Gerold103 committed Jan 10, 2024
1 parent 5bfe03b commit ac8f82b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
25 changes: 25 additions & 0 deletions test/storage-luatest/storage_1_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion vshard/storage/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit ac8f82b

Please sign in to comment.