Skip to content

Commit fce8f28

Browse files
committed
rebalancer: add replicaset.id in "Some buckets are not active" log
Before this patch the function `rebalancer_download_states` didn't return information about replicaset from which the states could not be downloaded. As a result, the log "Some buckets are not active ..." lacks of valuable information about unhealthy replicaset. Now, we return `(replicaset.id, nil)` instead of `nil` in case when rebalancer can't download state from this replicaset. Also we add replicaset.id in "Some buckets are not active ..." log. Also we change `rebalancer/rebalancer.test.lua` test which expected the old "Some buckets are not active" log without replicaset.id. Closes #212 NO_DOC=bugfix
1 parent e7da5b8 commit fce8f28

File tree

4 files changed

+35
-7
lines changed

4 files changed

+35
-7
lines changed

test/rebalancer/rebalancer.result

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,13 @@ _bucket:update({150}, {{'=', 2, vshard.consts.BUCKET.RECEIVING}})
318318
---
319319
- [150, 'receiving']
320320
...
321-
wait_rebalancer_state("Some buckets are not active", test_run)
321+
formatted_replicaset_uuid = string.gsub(util.replicasets[1], '%-', '%%-')
322+
---
323+
...
324+
log_msg = string.format('Some buckets in replicaset %s are not active', formatted_replicaset_uuid)
325+
---
326+
...
327+
wait_rebalancer_state(log_msg, test_run)
322328
---
323329
...
324330
_bucket:update({150}, {{'=', 2, vshard.consts.BUCKET.ACTIVE}})

test/rebalancer/rebalancer.test.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ util.map_bucket_protection(test_run, {REPLICASET_1}, false)
156156
test_run:switch('box_1_a')
157157
vshard.storage.rebalancer_enable()
158158
_bucket:update({150}, {{'=', 2, vshard.consts.BUCKET.RECEIVING}})
159-
wait_rebalancer_state("Some buckets are not active", test_run)
159+
formatted_replicaset_uuid = string.gsub(util.replicasets[1], '%-', '%%-')
160+
log_msg = string.format('Some buckets in replicaset %s are not active', formatted_replicaset_uuid)
161+
wait_rebalancer_state(log_msg, test_run)
160162
_bucket:update({150}, {{'=', 2, vshard.consts.BUCKET.ACTIVE}})
161163
vshard.storage.sync()
162164

test/storage-luatest/storage_1_1_1_test.lua

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,22 @@ rebalancer_recovery_group.test_rebalancer_routes_logging = function(g)
216216
g.replica_1_a:grep_log('The cluster is balanced ok.')
217217
end)
218218
end
219+
220+
rebalancer_recovery_group.test_no_log_spam_when_buckets_no_active = function(g)
221+
local moved_bucket = vtest.storage_first_bucket(g.replica_2_a)
222+
start_bucket_move(g.replica_1_a, g.replica_2_a, moved_bucket)
223+
wait_for_bucket_is_transferred(g.replica_1_a, g.replica_2_a, moved_bucket)
224+
vtest.storage_stop(g.replica_2_a)
225+
local buckets_not_active = string.format('Some buckets in replicaset ' ..
226+
'%s are not active',
227+
g.replica_2_a:replicaset_uuid())
228+
t.helpers.retrying({timeout = 60}, function()
229+
g.replica_1_a:exec(function()
230+
ivshard.storage.rebalancer_wakeup()
231+
end)
232+
t.assert(g.replica_1_a:grep_log(buckets_not_active))
233+
end)
234+
vtest.storage_start(g.replica_2_a, global_cfg)
235+
start_bucket_move(g.replica_2_a, g.replica_1_a, moved_bucket)
236+
wait_for_bucket_is_transferred(g.replica_2_a, g.replica_1_a, moved_bucket)
237+
end

vshard/storage/init.lua

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2798,7 +2798,7 @@ local function rebalancer_download_states()
27982798
replicaset, 'vshard.storage.rebalancer_request_state', {},
27992799
{timeout = consts.REBALANCER_GET_STATE_TIMEOUT})
28002800
if state == nil then
2801-
return
2801+
return nil, replicaset.id
28022802
end
28032803
local bucket_count = state.bucket_active_count +
28042804
state.bucket_pinned_count
@@ -2813,7 +2813,7 @@ local function rebalancer_download_states()
28132813
end
28142814
local sum = total_bucket_active_count + total_bucket_locked_count
28152815
if sum == M.total_bucket_count then
2816-
return replicasets, total_bucket_active_count
2816+
return total_bucket_active_count, replicasets
28172817
else
28182818
log.info('Total active bucket count is not equal to total. '..
28192819
'Possibly a boostrap is not finished yet. Expected %d, but '..
@@ -2837,18 +2837,19 @@ local function rebalancer_service_f(service)
28372837
end
28382838
service:set_activity('downloading states')
28392839
lfiber.testcancel()
2840-
local status, replicasets, total_bucket_active_count =
2840+
local status, total_bucket_active_count, replicasets =
28412841
pcall(rebalancer_download_states)
28422842
if M.module_version ~= module_version then
28432843
return
28442844
end
2845-
if not status or replicasets == nil then
2845+
if not status or total_bucket_active_count == nil then
28462846
if not status then
28472847
log.error(service:set_status_error(
28482848
'Error during downloading rebalancer states: %s',
28492849
replicasets))
28502850
end
2851-
log.info('Some buckets are not active, retry rebalancing later')
2851+
log.info('Some buckets in replicaset %s are not active, retry ' ..
2852+
'rebalancing later', replicasets)
28522853
service:set_activity('idling')
28532854
lfiber.testcancel()
28542855
lfiber.sleep(consts.REBALANCER_WORK_INTERVAL)

0 commit comments

Comments
 (0)