-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
storage: allow to choose rebalancer location #431
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
local t = require('luatest') | ||
local vtest = require('test.luatest_helpers.vtest') | ||
local vutil = require('vshard.util') | ||
|
||
local group_config = {{engine = 'memtx'}, {engine = 'vinyl'}} | ||
|
||
if vutil.feature.memtx_mvcc then | ||
table.insert(group_config, { | ||
engine = 'memtx', memtx_use_mvcc_engine = true | ||
}) | ||
table.insert(group_config, { | ||
engine = 'vinyl', memtx_use_mvcc_engine = true | ||
}) | ||
end | ||
|
||
local test_group = t.group('storage', group_config) | ||
|
||
local cfg_template = { | ||
sharding = { | ||
{ | ||
replicas = { | ||
replica_1_a = { | ||
master = true, | ||
}, | ||
replica_1_b = {}, | ||
}, | ||
}, | ||
{ | ||
replicas = { | ||
replica_2_a = { | ||
master = true, | ||
}, | ||
replica_2_b = {}, | ||
}, | ||
}, | ||
}, | ||
bucket_count = 16, | ||
rebalancer_mode = 'off', | ||
} | ||
local global_cfg | ||
|
||
test_group.before_all(function(g) | ||
cfg_template.memtx_use_mvcc_engine = g.params.memtx_use_mvcc_engine | ||
global_cfg = vtest.config_new(cfg_template) | ||
|
||
vtest.cluster_new(g, global_cfg) | ||
vtest.cluster_bootstrap(g, global_cfg) | ||
end) | ||
|
||
test_group.after_all(function(g) | ||
g.cluster:drop() | ||
end) | ||
|
||
local function find_rebalancer_name(g) | ||
local map, err = vtest.cluster_exec_each(g, function() | ||
return ivshard.storage.internal.rebalancer_fiber ~= nil | ||
end) | ||
t.assert_equals(err, nil) | ||
local rebalancer_name | ||
for name, has_rebalancer in pairs(map) do | ||
if has_rebalancer then | ||
t.assert_equals(rebalancer_name, nil) | ||
rebalancer_name = name | ||
end | ||
end | ||
return rebalancer_name | ||
end | ||
|
||
test_group.test_rebalancer_mode_off_no_marks = function(g) | ||
local _, err = vtest.cluster_exec_each(g, function() | ||
ilt.assert(not ivshard.storage.internal.rebalancer_fiber) | ||
end) | ||
t.assert_equals(err, nil) | ||
end | ||
|
||
test_group.test_rebalancer_mode_off_ignore_marks = function(g) | ||
local new_cfg_template = table.deepcopy(cfg_template) | ||
new_cfg_template.sharding[1].replicas.replica_1_a.rebalancer = true | ||
local new_cfg = vtest.config_new(new_cfg_template) | ||
vtest.cluster_cfg(g, new_cfg) | ||
local _, err = vtest.cluster_exec_each(g, function() | ||
ilt.assert(not ivshard.storage.internal.rebalancer_fiber) | ||
end) | ||
t.assert_equals(err, nil) | ||
-- Revert. | ||
vtest.cluster_cfg(g, global_cfg) | ||
end | ||
|
||
test_group.test_rebalancer_mode_auto_ignore_marks = function(g) | ||
local new_cfg_template = table.deepcopy(cfg_template) | ||
new_cfg_template.rebalancer_mode = 'auto' | ||
local new_cfg = vtest.config_new(new_cfg_template) | ||
local map, err = vtest.cluster_exec_each(g, function(cfg) | ||
-- Tell each instance it should be the rebalancer. But it must be | ||
-- ignored when mode = 'auto'. | ||
local info = box.info | ||
cfg.sharding[ivutil.replicaset_uuid(info)] | ||
.replicas[info.uuid].rebalancer = true | ||
local _, err = ivshard.storage.cfg(cfg, box.info.uuid) | ||
ilt.assert_equals(err, nil) | ||
return { | ||
has_rebalancer = ivshard.storage.internal.rebalancer_fiber ~= nil, | ||
uuid = box.info.uuid, | ||
} | ||
end, {new_cfg}) | ||
t.assert_equals(err, nil) | ||
local min_uuid | ||
local rebalancer_uuid | ||
for _, res in pairs(map) do | ||
if not min_uuid or min_uuid > res.uuid then | ||
min_uuid = res.uuid | ||
end | ||
if res.has_rebalancer then | ||
t.assert_equals(rebalancer_uuid, nil) | ||
rebalancer_uuid = res.uuid | ||
end | ||
end | ||
t.assert_equals(min_uuid, rebalancer_uuid) | ||
-- Revert. | ||
vtest.cluster_cfg(g, global_cfg) | ||
end | ||
|
||
test_group.test_rebalancer_mode_manual_no_marks = function(g) | ||
local new_cfg_template = table.deepcopy(cfg_template) | ||
new_cfg_template.rebalancer_mode = 'manual' | ||
local new_cfg = vtest.config_new(new_cfg_template) | ||
vtest.cluster_cfg(g, new_cfg) | ||
local _, err = vtest.cluster_exec_each(g, function() | ||
ilt.assert(not ivshard.storage.internal.rebalancer_fiber) | ||
end) | ||
t.assert_equals(err, nil) | ||
-- Revert. | ||
vtest.cluster_cfg(g, global_cfg) | ||
end | ||
|
||
test_group.test_rebalancer_mode_manual_with_mark = function(g) | ||
local new_cfg_template = table.deepcopy(cfg_template) | ||
new_cfg_template.rebalancer_mode = 'manual' | ||
|
||
-- Try a master. | ||
new_cfg_template.sharding[1].replicas.replica_1_a.rebalancer = true | ||
local new_cfg = vtest.config_new(new_cfg_template) | ||
vtest.cluster_cfg(g, new_cfg) | ||
t.assert_equals(find_rebalancer_name(g), 'replica_1_a') | ||
|
||
-- Try a replica. | ||
new_cfg_template.sharding[1].replicas.replica_1_a.rebalancer = nil | ||
new_cfg_template.sharding[2].replicas.replica_2_b.rebalancer = true | ||
new_cfg = vtest.config_new(new_cfg_template) | ||
vtest.cluster_cfg(g, new_cfg) | ||
t.assert_equals(find_rebalancer_name(g), 'replica_2_b') | ||
|
||
-- Ensure it works even on the replica. | ||
vtest.cluster_rebalancer_disable(g) | ||
g.replica_1_a:exec(function(rs2_uuid) | ||
while true do | ||
local bid = _G.get_first_bucket() | ||
if not bid then | ||
break | ||
end | ||
local _, err = ivshard.storage.bucket_send( | ||
bid, rs2_uuid, {timeout = iwait_timeout}) | ||
ilt.assert_equals(err, nil) | ||
end | ||
end, {g.replica_2_a:replicaset_uuid()}) | ||
vtest.cluster_rebalancer_enable(g) | ||
|
||
g.replica_2_b:exec(function() | ||
ivtest.service_wait_for_new_ok( | ||
ivshard.storage.internal.rebalancer_service, { | ||
on_yield = ivshard.storage.rebalancer_wakeup | ||
}) | ||
end) | ||
local _, err = vtest.cluster_exec_each_master(g, function(bucket_count) | ||
_G.bucket_gc_wait() | ||
ilt.assert_equals(ivshard.storage.buckets_count(), bucket_count) | ||
end, {new_cfg_template.bucket_count / #new_cfg_template.sharding}) | ||
t.assert_equals(err, nil) | ||
|
||
-- Revert. | ||
vtest.cluster_cfg(g, global_cfg) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test is flaky on my machine, latest tarantool master.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that is interesting! I couldn't reproduce it after a few hundreds runs. But I might see the reason, not related to the test or the patch. Does it reproduce on your machine reliably? If yes, then can you try with this diff?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see this error anymore.
ref
should be above goto. Applied the following:Diff
But other error pops up pretty often. Seems, bucket sending/receiving hangs:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've got it to fail only 2 times in an hour after thousands of runs. Can't gather enough info. Could you please gather some logs with this diff below?
Diff
I don't think that bucket sending hangs. It would fail earlier then. The error is at the waiting for GC to complete. Some SENT buckets are not GC-ed. Could be caused by my previous diff which ignores
M.rebalancer_transfering_buckets
. But I don't see any places where it could be set and then not unset back.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here're the logs:
logs.tar.gz
I'll try to investigate the issue tonight or tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the logs it looks like
M.rebalancer_transfering_buckets
is not a problem. It is completely empty when the failure happens. And no errors from bucket GC service reported. I would appreciate if you try to investigate it, thanks. I simply can't reproduce it except a couple of times per hour of running.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I finally figured this out. I applied the following patch. It's always bucket with id = 8, which hangs in SENT status.
Diff
replica_2_a
is the one, which failed. Here's its logs:replica_2_a
The bucket 8 is being sent, when gc tries to make it GARBAGE. It cannot do so and just skips it. The problem here is the fact, that gc says, that everything is all right. It updates
bucket_generation_collected
and never starts garbage collecting again:vshard/vshard/storage/init.lua
Lines 2478 to 2503 in b3c27b3
So, here's the patch, which stabilizes the test:
But it looks like
storage/scheduler
hangs with this patch. It also happens with initial patch, you proposed. Can you reproduce this hang?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the help! I found the reason, created a ticket for it because it is clearly not related to this PR: #433.
Also I probably will pause this PR. It might happen that we won't need it. I realized some things about how rebalancer will have to exist with
master='auto'
on storages, which might render this PR useless.