Skip to content

Commit 97965fb

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 4674bee commit 97965fb

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

test/storage-luatest/storage_1_1_1_test.lua

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,3 +224,26 @@ rebalancer_recovery_group.test_no_logs_while_unsuccess_recovery = function(g)
224224
end)
225225
end, {hanged_bucket_id})
226226
end
227+
228+
rebalancer_recovery_group.test_rebalancer_routes_logging = function(g)
229+
move_bucket(g.replica_2_a, g.replica_1_a,
230+
get_first_storage_bucket_id(g.replica_2_a))
231+
move_bucket(g.replica_3_a, g.replica_1_a,
232+
get_first_storage_bucket_id(g.replica_3_a))
233+
g.replica_1_a:exec(function()
234+
ivshard.storage.rebalancer_wakeup()
235+
end)
236+
t.helpers.retrying({timeout = 10}, function()
237+
t.assert(g.replica_1_a:grep_log(
238+
'Apply rebalancer routes with 1 workers'))
239+
end)
240+
t.assert(g.replica_1_a:grep_log('Move 1 bucket'))
241+
local route_1_to_2 = string.format('from %s to %s',
242+
g.replica_1_a:replicaset_uuid(),
243+
g.replica_2_a:replicaset_uuid())
244+
local route_1_to_3 = string.format('from %s to %s',
245+
g.replica_1_a:replicaset_uuid(),
246+
g.replica_3_a:replicaset_uuid())
247+
t.assert(g.replica_1_a:grep_log(route_1_to_2))
248+
t.assert(g.replica_1_a:grep_log(route_1_to_3))
249+
end

vshard/storage/init.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2882,6 +2882,10 @@ local function rebalancer_service_f(service)
28822882
-- incorrectly.
28832883
assert(next(routes) ~= nil)
28842884
for src_id, src_routes in pairs(routes) do
2885+
for dest_id, buckets_count in pairs(src_routes) do
2886+
log.info('Move %s bucket(s) from %s to %s',
2887+
buckets_count, src_id, dest_id)
2888+
end
28852889
service:set_activity('applying routes')
28862890
local rs = M.replicasets[src_id]
28872891
lfiber.testcancel()

0 commit comments

Comments
 (0)