Skip to content

Commit 2ab54d1

Browse files
anuthanAliaksey Artamonau
authored andcommitted
Add backfill stats to rebalance kv stats.
Helps with, MB-30803: Collect rebalance related stats Part of EPIC, MB-30894: Rebalance visibility and reporting Change-Id: I87bad9a8fae90ca9085c63a5d6358a196efc6cb6 Reviewed-on: http://review.couchbase.org/101824 Reviewed-by: Aliaksey Artamonau <[email protected]> Well-Formed: Build Bot <[email protected]> Tested-by: Aliaksey Artamonau <[email protected]>
1 parent 44df809 commit 2ab54d1

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

src/ns_rebalance_observer.erl

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,14 @@
4545
-record(vbucket_info, {before_chain :: [node()],
4646
after_chain :: [node()],
4747
stats :: [#replica_building_stats{}],
48-
move = #stat_info{}}).
48+
move = #stat_info{},
49+
backfill = #stat_info{}}).
4950

5051
-record(total_stat_info, {total_time = 0,
5152
completed_count = 0}).
5253

5354
-record(vbucket_level_info, {move = #total_stat_info{},
55+
backfill = #total_stat_info{},
5456
vbucket_info = dict:new()}).
5557

5658
-record(compaction_info, {per_node = [] :: [{node(), #total_stat_info{}}],
@@ -114,6 +116,10 @@ is_interesting_master_event({_, compaction_uninhibit_started, _BucketName, _}) -
114116
fun handle_compaction_uninhibit/2;
115117
is_interesting_master_event({_, compaction_uninhibit_done, _BucketName, _}) ->
116118
fun handle_compaction_uninhibit/2;
119+
is_interesting_master_event({_, backfill_phase_started, _BucketName, _VBucketId}) ->
120+
fun handle_generic_vb_stat_event/2;
121+
is_interesting_master_event({_, backfill_phase_ended, _BucketName, _VBucketId}) ->
122+
fun handle_generic_vb_stat_event/2;
117123
is_interesting_master_event(_) ->
118124
undefined.
119125

@@ -374,6 +380,9 @@ handle_vbucket_move_done({TS, vbucket_move_done, BucketName, VBucket},
374380
handle_compaction_uninhibit({TS, Event, BucketName, Node}, State) ->
375381
{noreply, update_info(Event, State, {TS, BucketName, Node})}.
376382

383+
handle_generic_vb_stat_event({TS, Event, BucketName, VBucket}, State) ->
384+
{noreply, update_info(Event, State, {TS, BucketName, VBucket})}.
385+
377386
update_move(State, BucketName, VBucket, Fun) ->
378387
update_all_vb_info(State, BucketName,
379388
dict:update(VBucket, Fun,
@@ -679,7 +688,12 @@ find_event_action(Event) ->
679688
{vbucket_move_start, undefined,
680689
#vbucket_info.move, start_time},
681690
{vbucket_move_done, #vbucket_level_info.move,
682-
#vbucket_info.move, end_time}
691+
#vbucket_info.move, end_time},
692+
693+
{backfill_phase_started, undefined,
694+
#vbucket_info.backfill, start_time},
695+
{backfill_phase_ended, #vbucket_level_info.backfill,
696+
#vbucket_info.backfill, end_time}
683697
],
684698
lists:keyfind(Event, 1, EventAction).
685699

@@ -776,12 +790,14 @@ construct_replica_building_stats_json(#replica_building_stats{node = Node,
776790
construct_vbucket_info_json(Id, #vbucket_info{before_chain = BC,
777791
after_chain = AC,
778792
stats = RBS,
779-
move = Move}) ->
793+
move = Move,
794+
backfill = Backfill}) ->
780795
{[{id, Id},
781796
{beforeChain, BC},
782797
{afterChain, AC},
783798
{stats, {[construct_replica_building_stats_json(X) || X <- RBS]}},
784-
{move, construct_stat_info_json(Move)}]}.
799+
{move, construct_stat_info_json(Move)},
800+
{backfill, construct_stat_info_json(Backfill)}]}.
785801

786802
construct_vbucket_level_info_json(VBLevelInfo, Options) ->
787803
case dict:is_empty(VBLevelInfo#vbucket_level_info.vbucket_info) of
@@ -794,6 +810,7 @@ construct_vbucket_level_info_json(VBLevelInfo, Options) ->
794810

795811
construct_vbucket_level_info_json_inner(
796812
#vbucket_level_info{move = Move,
813+
backfill = Backfill,
797814
vbucket_info = AllVBInfo}, Options) ->
798815
VBI = case proplists:get_bool(add_vbucket_info, Options) of
799816
true ->
@@ -804,7 +821,8 @@ construct_vbucket_level_info_json_inner(
804821
_ ->
805822
[]
806823
end,
807-
{[{move, construct_total_stat_info_json(Move)}]
824+
{[{move, construct_total_stat_info_json(Move)},
825+
{backfill, construct_total_stat_info_json(Backfill)}]
808826
++ VBI}.
809827

810828
get_all_stage_rebalance_details(#state{bucket_info = BucketLevelInfo},

0 commit comments

Comments
 (0)