Skip to content

Commit b507c32

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=bugfx
1 parent 2abe583 commit b507c32

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
@@ -190,3 +190,26 @@ rebalancer_recovery_group.test_no_logs_while_unsuccess_recovery = function(g)
190190
end)
191191
end, {hanged_bucket_id})
192192
end
193+
194+
rebalancer_recovery_group.test_rebalancer_routes_logging = function(g)
195+
move_bucket(g.replica_2_a, g.replica_1_a,
196+
get_first_storage_bucket_id(g.replica_2_a))
197+
move_bucket(g.replica_3_a, g.replica_1_a,
198+
get_first_storage_bucket_id(g.replica_3_a))
199+
g.replica_1_a:exec(function()
200+
ivshard.storage.rebalancer_wakeup()
201+
end)
202+
t.helpers.retrying({timeout = 10}, function()
203+
t.assert(g.replica_1_a:grep_log(
204+
'Apply rebalancer routes with 1 workers'))
205+
end)
206+
t.assert(g.replica_1_a:grep_log('Move 1 bucket'))
207+
local route_1_to_2 = string.format('from %s to %s',
208+
g.replica_1_a:replicaset_uuid(),
209+
g.replica_2_a:replicaset_uuid())
210+
local route_1_to_3 = string.format('from %s to %s',
211+
g.replica_1_a:replicaset_uuid(),
212+
g.replica_3_a:replicaset_uuid())
213+
t.assert(g.replica_1_a:grep_log(route_1_to_2))
214+
t.assert(g.replica_1_a:grep_log(route_1_to_3))
215+
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)