Skip to content

Commit 5348422

Browse files
committed
rebalancer: add logging of routes
This patch adds rebalancer routes' logging. The log file now includes information about the source storage, the number of buckets, and the destination storage where the buckets will be moved. Part of #212 NO_DOC=bugfix
1 parent 355df43 commit 5348422

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

test/storage-luatest/storage_1_1_1_test.lua

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,28 @@ rebalancer_recovery_group.test_no_logs_while_unsuccess_recovery = function(g)
195195
assert_bucket_is_transferred(g.replica_2_a, g.replica_1_a,
196196
hanged_bucket_id_2)
197197
end
198+
199+
rebalancer_recovery_group.test_rebalancer_routes_logging = function(g)
200+
local moved_bucket_from_2 = vtest.storage_first_bucket(g.replica_2_a)
201+
start_bucket_move(g.replica_2_a, g.replica_1_a, moved_bucket_from_2)
202+
local moved_bucket_from_3 = vtest.storage_first_bucket(g.replica_3_a)
203+
start_bucket_move(g.replica_3_a, g.replica_1_a, moved_bucket_from_3)
204+
t.helpers.retrying({timeout = 60}, function()
205+
g.replica_1_a:exec(function()
206+
ivshard.storage.rebalancer_wakeup()
207+
end)
208+
t.assert(g.replica_1_a:grep_log(
209+
'Apply rebalancer routes with 1 workers'))
210+
end)
211+
local rebalancer_routes_msg = string.format("{\"%s\":{\"%s\":1,\"%s\":1}}",
212+
g.replica_1_a:replicaset_uuid(),
213+
g.replica_3_a:replicaset_uuid(),
214+
g.replica_2_a:replicaset_uuid())
215+
t.assert(g.replica_1_a:grep_log(rebalancer_routes_msg))
216+
start_bucket_move(g.replica_1_a, g.replica_2_a, moved_bucket_from_2)
217+
start_bucket_move(g.replica_1_a, g.replica_3_a, moved_bucket_from_3)
218+
assert_bucket_is_transferred(g.replica_1_a, g.replica_2_a,
219+
moved_bucket_from_2)
220+
assert_bucket_is_transferred(g.replica_1_a, g.replica_3_a,
221+
moved_bucket_from_3)
222+
end

vshard/storage/init.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2885,6 +2885,7 @@ local function rebalancer_service_f(service)
28852885
-- then max_disbalance would have been calculated
28862886
-- incorrectly.
28872887
assert(next(routes) ~= nil)
2888+
log.info(json_encode(routes))
28882889
for src_id, src_routes in pairs(routes) do
28892890
service:set_activity('applying routes')
28902891
local rs = M.replicasets[src_id]

0 commit comments

Comments
 (0)