Skip to content

Commit

Permalink
storage: introduce name identification
Browse files Browse the repository at this point in the history
This commit allows storage to use named config identification.

Part of tarantool#426

@TarantoolBot document
Title: vshard: vshard.storage.cfg argument change

vshard.storage.cfg(cfg, instance_id)

Configure the database and start sharding for the specified storage
instance. `istance_id` depends on `identification_mode` used in config.
If it's 'uuid_as_key', which is default, then UUID must be used.
Otherwise - instance_name.

Parameters:
    cfg – a storage configuration
    instance_id – UUID or name of the instance
  • Loading branch information
Serpentian committed Dec 4, 2023
1 parent 908a672 commit 0e590c5
Show file tree
Hide file tree
Showing 3 changed files with 265 additions and 172 deletions.
60 changes: 60 additions & 0 deletions test/storage-luatest/storage_1_1_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -530,3 +530,63 @@ test_group.test_noactivity_timeout_for_explicit_master = function(g)
_G.bucket_gc_wait()
end, {g.replica_1_a:replicaset_uuid(), bid})
end

test_group.test_named_config_identification = function(g)
t.run_only_if(vutil.version_is_at_least(3, 0, 0, 'entrypoint', 0, 0))
local new_cfg_template = table.deepcopy(cfg_template)
new_cfg_template.identification_mode = 'name_as_key'
new_cfg_template.sharding['replicaset_1'] = new_cfg_template.sharding[1]
new_cfg_template.sharding['replicaset_2'] = new_cfg_template.sharding[2]
new_cfg_template.sharding[1] = nil
new_cfg_template.sharding[2] = nil
local new_global_cfg = vtest.config_new(new_cfg_template)

-- Attempt to configure with named config without name set causes error.
g.replica_1_a:exec(function(cfg)
ilt.assert_error_msg_contains('Instance name mismatch',
ivshard.storage.cfg, cfg, 'replica_1_a')
end, {new_global_cfg})

-- Set names on all replicas.
g.replica_1_a:exec(function()
box.cfg{instance_name = 'replica_1_a', replicaset_name = 'replicaset_1'}
end)
g.replica_2_a:exec(function()
box.cfg{instance_name = 'replica_2_a', replicaset_name = 'replicaset_2'}
end)

-- Now the config can be finally applied.
vtest.cluster_cfg(g, new_global_cfg)

-- Test, that sending by name works properly
local rs_name_2 = g.replica_2_a:replicaset_name()
t.assert_equals(rs_name_2, 'replicaset_2')
g.replica_1_a:exec(function(name)
local bid = _G.get_first_bucket()
local ok, err = ivshard.storage.bucket_send(
bid, name, {timeout = _G.iwait_timeout})
ilt.assert_equals(err, nil)
ilt.assert(ok)
end, {rs_name_2})

-- Test, that rebalancer is also ok.
vtest.cluster_rebalancer_enable(g)
g.replica_1_a:exec(function()
local internal = ivshard.storage.internal
ivtest.service_wait_for_ok(internal.rebalancer_service,
{on_yield = ivshard.storage.rebalancer_wakeup})

-- Cleanup
_G.bucket_recovery_wait()
_G.bucket_gc_wait()
end)

g.replica_2_a:exec(function()
_G.bucket_recovery_wait()
_G.bucket_gc_wait()
end)

vtest.cluster_rebalancer_disable(g)
-- Back to UUID identification.
vtest.cluster_cfg(g, global_cfg)
end
14 changes: 7 additions & 7 deletions test/unit/rebalancer.result
Original file line number Diff line number Diff line change
Expand Up @@ -1078,9 +1078,9 @@ d
map:
uuid:
bucket_count: 0
id: uuid
progress: 0
is_throttle_warned: false
uuid: uuid
need_to_send: 15
...
d = dispenser.create({uuid1 = 5, uuid2 = 5})
Expand All @@ -1099,13 +1099,13 @@ u, d
prev: &1
bucket_count: 5
next: *0
id: uuid1
progress: 0
is_throttle_warned: false
uuid: uuid1
need_to_send: 5
id: uuid2
progress: 0
is_throttle_warned: false
uuid: uuid2
need_to_send: 5
first: *1
map:
Expand All @@ -1124,13 +1124,13 @@ d
prev: &1
bucket_count: 5
next: *0
id: uuid1
progress: 0
is_throttle_warned: false
uuid: uuid1
need_to_send: 5
id: uuid2
progress: 0
is_throttle_warned: false
uuid: uuid2
need_to_send: 5
first: *1
map:
Expand All @@ -1150,13 +1150,13 @@ d
prev: &1
bucket_count: 5
next: *0
id: uuid1
progress: 0
is_throttle_warned: false
uuid: uuid1
need_to_send: 5
id: uuid2
progress: 0
is_throttle_warned: true
uuid: uuid2
need_to_send: 5
first: *1
map:
Expand Down
Loading

0 comments on commit 0e590c5

Please sign in to comment.