Skip to content

Commit e11f8d6

Browse files
committed
recovery: add logging of recovered buckets
This patch introduces logging of buckets' ids which were recovered during recovery stage of storage. Part of #212 NO_DOC=bugfix
1 parent 60b62ca commit e11f8d6

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

test/storage-luatest/storage_1_1_1_test.lua

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,13 @@ rebalancer_recovery_group.test_no_logs_while_unsuccess_recovery = function(g)
187187
ivshard.storage.recovery_wakeup()
188188
end)
189189
g.replica_1_a:exec(function() ivshard.storage.recovery_wakeup() end)
190-
t.assert(g.replica_1_a:grep_log('Finish bucket recovery step, 2 ' ..
191-
'sending buckets are recovered among'))
190+
-- In some rare cases the recovery service can recover buckets one
191+
-- by one. As a result we get multiple "Finish bucket recovery" and
192+
-- "Recovery buckets" logs with different bucket ids and buckets'
193+
-- count. That is why we should grep general logs without buckets'
194+
-- count and bucket ids to avoid flakiness.
195+
t.assert(g.replica_1_a:grep_log('Finish bucket recovery step'))
196+
t.assert(g.replica_1_a:grep_log('Recovered buckets'))
192197
end)
193198
wait_for_bucket_is_transferred(g.replica_2_a, g.replica_1_a,
194199
hanged_bucket_id_1)

vshard/storage/init.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ local lmsgpack = require('msgpack')
55
local netbox = require('net.box') -- for net.box:self()
66
local trigger = require('internal.trigger')
77
local ffi = require('ffi')
8+
local json_encode = require('json').encode
89
local yaml_encode = require('yaml').encode
910
local fiber_clock = lfiber.clock
1011
local fiber_yield = lfiber.yield
@@ -931,6 +932,7 @@ local function recovery_step_by_type(type)
931932
local recovered = 0
932933
local total = 0
933934
local start_format = 'Starting %s buckets recovery step'
935+
local recovered_buckets = {SENT = {}, GARBAGE = {}, ACTIVE = {}}
934936
for _, bucket in _bucket.index.status:pairs(type) do
935937
lfiber.testcancel()
936938
total = total + 1
@@ -990,12 +992,15 @@ local function recovery_step_by_type(type)
990992
if recovery_local_bucket_is_sent(bucket, remote_bucket) then
991993
_bucket:update({bucket_id}, {{'=', 2, BSENT}})
992994
recovered = recovered + 1
995+
table.insert(recovered_buckets['SENT'], bucket_id)
993996
elseif recovery_local_bucket_is_garbage(bucket, remote_bucket) then
994997
_bucket:update({bucket_id}, {{'=', 2, BGARBAGE}})
995998
recovered = recovered + 1
999+
table.insert(recovered_buckets['SENT'], bucket_id)
9961000
elseif recovery_local_bucket_is_active(bucket, remote_bucket) then
9971001
_bucket:replace({bucket_id, BACTIVE})
9981002
recovered = recovered + 1
1003+
table.insert(recovered_buckets['ACTIVE'], bucket_id)
9991004
elseif is_step_empty then
10001005
log.info('Bucket %s is %s local and %s on replicaset %s, waiting',
10011006
bucket_id, bucket.status, remote_bucket.status, peer_id)
@@ -1005,7 +1010,8 @@ local function recovery_step_by_type(type)
10051010
end
10061011
if recovered > 0 then
10071012
log.info('Finish bucket recovery step, %d %s buckets are recovered '..
1008-
'among %d', recovered, type, total)
1013+
'among %d. Recovered buckets: %s', recovered, type, total,
1014+
json_encode(recovered_buckets))
10091015
end
10101016
return total, recovered
10111017
end

0 commit comments

Comments
 (0)