Skip to content

Commit 2691757

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 0c2d5db commit 2691757

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
@@ -932,6 +933,7 @@ local function recovery_step_by_type(type, limiter)
932933
local recovered = 0
933934
local total = 0
934935
local start_format = 'Starting %s buckets recovery step'
936+
local recovered_buckets = {SENT = {}, GARBAGE = {}, ACTIVE = {}}
935937
for _, bucket in _bucket.index.status:pairs(type) do
936938
lfiber.testcancel()
937939
total = total + 1
@@ -992,12 +994,15 @@ local function recovery_step_by_type(type, limiter)
992994
if recovery_local_bucket_is_sent(bucket, remote_bucket) then
993995
_bucket:update({bucket_id}, {{'=', 2, BSENT}})
994996
recovered = recovered + 1
997+
table.insert(recovered_buckets['SENT'], bucket_id)
995998
elseif recovery_local_bucket_is_garbage(bucket, remote_bucket) then
996999
_bucket:update({bucket_id}, {{'=', 2, BGARBAGE}})
9971000
recovered = recovered + 1
1001+
table.insert(recovered_buckets['SENT'], bucket_id)
9981002
elseif recovery_local_bucket_is_active(bucket, remote_bucket) then
9991003
_bucket:replace({bucket_id, BACTIVE})
10001004
recovered = recovered + 1
1005+
table.insert(recovered_buckets['ACTIVE'], bucket_id)
10011006
elseif is_step_empty then
10021007
log.info('Bucket %s is %s local and %s on replicaset %s, waiting',
10031008
bucket_id, bucket.status, remote_bucket.status, peer_id)
@@ -1007,7 +1012,8 @@ local function recovery_step_by_type(type, limiter)
10071012
end
10081013
if recovered > 0 then
10091014
log.info('Finish bucket recovery step, %d %s buckets are recovered '..
1010-
'among %d', recovered, type, total)
1015+
'among %d. Recovered buckets: %s', recovered, type, total,
1016+
json_encode(recovered_buckets))
10111017
end
10121018
return total, recovered
10131019
end

0 commit comments

Comments
 (0)