Skip to content

Commit 1da893d

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 c509e0b commit 1da893d

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-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
@@ -174,3 +174,28 @@ rebalancer_recovery_group.test_no_logs_while_unsuccess_recovery = function(g)
174174
end)
175175
end, {hanged_bucket_id})
176176
end
177+
178+
rebalancer_recovery_group.test_rebalancer_routes_logging = function(g)
179+
local moved_bucket_from_2 = vtest.storage_first_bucket(g.replica_2_a)
180+
local moved_bucket_from_3 = vtest.storage_first_bucket(g.replica_3_a)
181+
move_bucket(g.replica_2_a, g.replica_1_a, moved_bucket_from_2)
182+
move_bucket(g.replica_3_a, g.replica_1_a, moved_bucket_from_3)
183+
g.replica_1_a:exec(function()
184+
ivshard.storage.rebalancer_wakeup()
185+
end)
186+
t.helpers.retrying({timeout = 60}, function()
187+
t.assert(g.replica_1_a:grep_log(
188+
'Apply rebalancer routes with 1 workers'))
189+
end)
190+
t.assert(g.replica_1_a:grep_log('Move 1 bucket'))
191+
local route_1_to_2 = string.format('from %s to %s',
192+
g.replica_1_a:replicaset_uuid(),
193+
g.replica_2_a:replicaset_uuid())
194+
local route_1_to_3 = string.format('from %s to %s',
195+
g.replica_1_a:replicaset_uuid(),
196+
g.replica_3_a:replicaset_uuid())
197+
t.assert(g.replica_1_a:grep_log(route_1_to_2))
198+
t.assert(g.replica_1_a:grep_log(route_1_to_3))
199+
move_bucket(g.replica_1_a, g.replica_2_a, moved_bucket_from_2)
200+
move_bucket(g.replica_1_a, g.replica_3_a, moved_bucket_from_3)
201+
end

vshard/storage/init.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
local log = require('log')
22
local luri = require('uri')
33
local lfiber = require('fiber')
4+
local json_encode = require('json').encode
45
local lmsgpack = require('msgpack')
56
local netbox = require('net.box') -- for net.box:self()
67
local trigger = require('internal.trigger')
@@ -2882,6 +2883,13 @@ local function rebalancer_service_f(service)
28822883
-- incorrectly.
28832884
assert(next(routes) ~= nil)
28842885
for src_id, src_routes in pairs(routes) do
2886+
local routes_info = {}
2887+
for dest_id, buckets_count in pairs(src_routes) do
2888+
table.insert(routes_info,
2889+
string.format('Move %s bucket(s) from %s to %s',
2890+
buckets_count, src_id, dest_id))
2891+
end
2892+
log.info(json_encode(routes_info))
28852893
service:set_activity('applying routes')
28862894
local rs = M.replicasets[src_id]
28872895
lfiber.testcancel()

0 commit comments

Comments
 (0)