Skip to content

Commit 04c506f

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 9a0cea2 commit 04c506f

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

test/storage-luatest/storage_1_1_1_test.lua

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,32 @@ rebalancer_recovery_group.test_no_logs_while_unsuccess_recovery = function(g)
193193
assert_bucket_is_transferred(g.replica_2_a, g.replica_1_a,
194194
hanged_bucket_id_2)
195195
end
196+
197+
rebalancer_recovery_group.test_rebalancer_routes_logging = function(g)
198+
local moved_bucket_from_2 = vtest.storage_first_bucket(g.replica_2_a)
199+
start_bucket_move(g.replica_2_a, g.replica_1_a, moved_bucket_from_2)
200+
local moved_bucket_from_3 = vtest.storage_first_bucket(g.replica_3_a)
201+
start_bucket_move(g.replica_3_a, g.replica_1_a, moved_bucket_from_3)
202+
g.replica_1_a:exec(function()
203+
ivshard.storage.rebalancer_wakeup()
204+
end)
205+
t.helpers.retrying({timeout = 60}, function()
206+
t.assert(g.replica_1_a:grep_log(
207+
'Apply rebalancer routes with 1 workers'))
208+
end)
209+
t.assert(g.replica_1_a:grep_log('Move 1 bucket'))
210+
local route_1_to_2 = string.format('from %s to %s',
211+
g.replica_1_a:replicaset_uuid(),
212+
g.replica_2_a:replicaset_uuid())
213+
local route_1_to_3 = string.format('from %s to %s',
214+
g.replica_1_a:replicaset_uuid(),
215+
g.replica_3_a:replicaset_uuid())
216+
t.assert(g.replica_1_a:grep_log(route_1_to_2))
217+
t.assert(g.replica_1_a:grep_log(route_1_to_3))
218+
start_bucket_move(g.replica_1_a, g.replica_2_a, moved_bucket_from_2)
219+
start_bucket_move(g.replica_1_a, g.replica_3_a, moved_bucket_from_3)
220+
assert_bucket_is_transferred(g.replica_1_a, g.replica_2_a,
221+
moved_bucket_from_2)
222+
assert_bucket_is_transferred(g.replica_1_a, g.replica_3_a,
223+
moved_bucket_from_3)
224+
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')
@@ -2885,6 +2886,13 @@ local function rebalancer_service_f(service)
28852886
-- incorrectly.
28862887
assert(next(routes) ~= nil)
28872888
for src_id, src_routes in pairs(routes) do
2889+
local routes_info = {}
2890+
for dest_id, buckets_count in pairs(src_routes) do
2891+
table.insert(routes_info,
2892+
string.format('Move %s bucket(s) from %s to %s',
2893+
buckets_count, src_id, dest_id))
2894+
end
2895+
log.info(json_encode(routes_info))
28882896
service:set_activity('applying routes')
28892897
local rs = M.replicasets[src_id]
28902898
lfiber.testcancel()

0 commit comments

Comments
 (0)